Вопрос

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