Hi
I did get the below mentioned script created by LucD in one of the answers to a community
$VM = (Get-Content c:\temp\servers.txt)
foreach($vm in Get-VM -Name $VM){
Shutdown-VMguest -VM $vm -confirm:$false
while ($vm.ExtensionData.Runtime.PowerState -eq "poweredOn"){
Start-Sleep -Seconds 2
$vm.ExtensionData.UpdateViewData("Runtime.PowerState")
}
New-Snapshot -VM $vm -name (get-date)
Start-VM -VM $vm
}
That helps me to start, though what my requirement is :-
Shutdown a VM
Check for ping status
Once down, take snapshot with the name as of that date & time, send a confirmation e-mail, say on Monday
Power on the machine. send a confirmation e-mail.
Same script will be scheduled to run after 2 day to have another snapshot on the same machine, say on Wed.
Now on Fri, I need to take another snapshot of the name with that days date & time, once done
Delete the snapshot that was taken on Monday.
Power on the machine.
And it goes on ...as again on Mon, new snapshot after powering down & deleting the oldest snapshot i.e. taken on Wed. & then power it on send a confirmation e-mail.