[英]Renaming Description of snapshot vmware using powercli (powershell)
我正在尝试编辑vcenter中存在的所有快照的描述字段。 该脚本能够正确找到快照,并尝试对其进行编辑,我可以将任务视为重命名快照,但实际上未反映更改。 有人可以帮我解决这个问题吗? 提前致谢。
Get-Module -Name VMware* -ListAvailable | Import-Module
$AllSnaps = @()
$User = "Domain\UserName"
$File = "Credentials.txt"
$MyCredential=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)
foreach ($VC in $VCServers) {
$Stat = connect-viserver $VC -credential $MyCredential -erroraction 'silentlycontinue'
if($Stat.IsConnected){
write-host "Connected to VC - $VC"
$AllSnaps = Get-VM | Get-Snapshot | select VM, Name, Description
ForEach ($Snap in $AllSnaps) {
If ($($Snap.Name) -Match "NBU_SNAPSHOT" -or $($Snap.Description) -Match "PERM-") {
Write-host "No Action required in these VM's"
} else {
$NewDesc = "PERM-"+$($Snap.description)
get-vm -name $($snap.vm) | get-snapshot -name $($Snap.name) | set-snapshot -description $NewDesc
}
}
disconnect-viserver -Server $VC -Force -confirm:$False
}
}
foreach($snap in $AllSnaps){get-vm -name $snap.vm | get-snapshot -name
$Snap.name | set-snapshot -description "blah"}
删除括号的作品。
然后答案可能显示为未设置,因为您必须重新获取$ AllSnaps
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.