Vmware PowerShell(快照管理)
Write-Host -ForegroundColor Blue "start!"
#connect-viserver -server ** -user ** -password **
$VMsList=Import-Csv C:\Users\liuzhx\Desktop\powerCli_script\Snap_Create\Snapshot-Create.csv -Encoding Default #加载虚拟机清单
#$custSysprep = Get-OSCustomizationSpec -Name "Linux"
$outlogpath="C:\Users\liuzhx\Desktop\powerCli_script\Snap_Create\create_snap_log.txt"
$date=Get-Date
echo "================$date=================" | Out-File -Append $outlogpath
foreach($vms in $VMsList)
{
$vmName=$vms.ame #虚拟机名称
$vc_ip=$vms.vc
connect-viserver -server $vc_ip -user user@vsphere.local -password VMware@2017
$get_vmname=Get-VM $vmName
if ($get_vmname)
{
Write-Host "vc:$vc_ip $vmName $date"
Get-VM $vmName | New-S