Reply to Message

View discussion in a popup

Replying to:
mark_chuman
Hot Shot
Hot Shot

Thanks Luc.  Any idea how to get this into a foreach loop?

$CSVhosts = Import-Csv .\$OldvCenters\$Cluster\VMHost.csv

$esx = Get-VMHost -Name $CSVhosts.name

foreach ($vmshost in $CSVhosts) {$esx.ExtenionData.Destroy_Task()}

Results in:

Action to take for this exception:

You cannot call a method on a null-valued expression.

[C] Continue  [I] Silently Continue  [B] Break  [S] Suspend  [?] Help (default is "C"): C

what i was using before.

$CSVhosts = Import-Csv .\$OldvCenters\$Cluster\VMHost.csv

foreach ($vmhost in $CSVhosts) {Remove-VMHost -VMHost $vmhost.name -confirm:$false}

I'm sure I'm mutilating this one.

Reply
0 Kudos