Hello,
is it possible to plan a snapshot of a VM automatically via taskplaner etc.?
Thanks
Dennis
Hi Dennis,
you could use the Windows task scheduler to run a PowerCLI script.
New-Snapshot -VM $VM -Name $Snapshotname -description "$Snapshotdescription"
The other option is to vCenters "Scheduled Tasks" to create it.
Hi Dennis,
you could use the Windows task scheduler to run a PowerCLI script.
New-Snapshot -VM $VM -Name $Snapshotname -description "$Snapshotdescription"
The other option is to vCenters "Scheduled Tasks" to create it.
just quick and dirty no error handling and nothing....
$Snapin = "VMware.VimAutomation.Core"
$vCenterServer = "hostnameofvcenteroresxi"
$User = "root"
$Password = "password"
$VM = "vmtest"
$SnapshotName = "foo"
$SnapshotDesc = "foo bar"
function LoadSnapin {
param (
$Snapin)
process {
If ((Get-PSSnapin $Snapin -ErrorAction SilentlyContinue) -eq $null)
{
Write-Host Loading Snapin $Snapin
Add-PSSnapin $Snapin -WarningAction SilentlyContinue
}
}
}
function ConnectVI {
param (
$vCenterServer)
Write-Host 'Connecting to vCenter' $vCenterServer
Connect-VIServer -Server $vCenterServer -User $User -Password $Password -WarningAction SilentlyContinue
}
function DisconnectVI {
param (
$vCenterServer)
Write-Host 'Disconnecting from vCenter' $vCenterServer
Disconnect-VIServer $vCenterServer -Confirm:$false -WarningAction SilentlyContinue
}
LoadSnapin $Snapin
ConnectVI $vCenterServer
New-Snapshot -VM $VM -Name $SnapshotName -Description $SnapshotDesc -Confirm:$false
DisconnectVI $vCenterServer
exit 0