Welcome to the Community,
although it might be possible to do this using PowerCLI, I think this is more something you should do on the guest OS level, i.e. running a script which interacts directly with the specific guest OS rather than with the ESXi host!?
André