#snippets folder didn't exist so I created it
mkdir /var/lib/vz/snippets
#Copied the template to the folder
cp /usr/share/pve-docs/examples/guest-example-hookscript.pl /var/lib/vz/snippets/secon-hookscript.pl
#modified the perl script with the applicable commands
nano /var/lib/vz/snippets/secon-hookscript.pl
# Made it executable
chmod +x /var/lib/vz/snippets/secon-hookscript.pl
#Set it to the applicable VM
qm set 102 --hookscript local:snippets/secon-hookscript.pl