문제

I'm working on a VSphere CLI script that will take 6 snapshots and allow me to make the description of each snapshot be the date it was created. At the moment here's the code that I'm trying:

$server = "<ServerName>"
connect-VIserver $server
$snapshot = Get-vm | New-Snapshot -Name $"<serverName>" | Set-Snapshot -$snapshot -Description get-date
도움이 되었습니까?

해결책

You can do this in one call

Get-VM | New-Snapshot -Name "$serverName" -Description (Get-Date)

I'm not sure why you want to do this as, the snapshot object has a property called "Created" You can get it by doing something like this:

$snapshots = Get-VM | New-Snapshot -Name "$serverName"

$snapshots | foreach { Set-Snapshot -Description $_.Created }

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top