Reply to Message

View discussion in a popup

Replying to:
mark_chuman
Hot Shot
Hot Shot

Interesting.  The csv contents look good and the write-host is spitting out the correct name.

$SourcevCenter = "vcenter name"

$Cluster = "cluster name"

Import-Csv .\$SourcevCenter\$Cluster\VMHost.csv | %{

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

   Write-Host $esx

   $esx.ExtenionData.Destroy_Task()

}

Additional notes:

When I intentionally input an incorrect server name into the csv I receive and additional error regarding the host not being found, but this is coming from the "Get-VMHost" when setting the $esx variable.

Get-VMHost : 06/24/2014 8:49:55 AM    Get-VMHost        VMHost with name 'incorrect server name' was not found using the specified filter(s).

At C:\Scripts\Working\Evaluating\loop.ps1:6 char:11

+    $esx = Get-VMHost -Name $_.name

+           ~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (:) [Get-VMHost], VimException

    + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost

Reply
0 Kudos