In my script, I am reverting the snapshot with these commands.
$TARGET_VM = Get-VM $vm_name
$TARGET_SNAP = Get-Snapshot -VM $TARGET_VM -Name $snap_name
Set-VM -VM $TARGET_VM -Snapshot $TARGET_SNAP -Confirm:$false
After reverting the snapshot, I need to run bunch of commands, but the commands fails as the system is not ready yet to receive the command.
After snapshot is reverted, If I launch the web console, I see that the timestamp matches with the time when it was created (a week before). System doesn't respond to any mouse interactions, It feels like the Virtual machine is busy updating the timestamp. Due to this, even the successive commands fail.
I verified that "C:\Program Files\VMware\VMware Tools>VMwareToolboxCmd.exe timesync status" output is 'Enabled'
I also tried executing w32tm command after snapshot is reverted: "PsExec \\$vm_ip -h -d -u `"$vm_user`" -p `"$vm_pass`" -i cmd.exe /c `"w32tm /resync`"
But the system fails to execute the command as it is busy syncing the time.
As a workaround, I have introduced a hard wait. But please suggest if any such below option is available or if there is a better way to wait for the script until the system is ready to accept the commands.