Hi All,
I have a list of around 600 VM's but not sure whether these VM's still exist or running in Vcenter or migrated to the Cloud. Can we confirm from power cli whether the VM's from list C:\temp\vmlist exist or running on the vc? Example VC name - vc01.
thanks
vmk
If the VMs running in the cloud are not found from with your connection to the vCenter(s), you could do
ForEach-Object -Process {
$obj = [ordered]@{
VM = $_
}
$vm = Get-VM -Name $_ -ErrorAction SilentlyContinue
if ($vm)
{
$obj.Add('VC', ([uri]$vm.ExtensionData.Client.ServiceUrl).Host)
}
else
{
$obj.Add('VC', 'VM not found')
}
New-Object PSObject -Property $obj
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If the VMs running in the cloud are not found from with your connection to the vCenter(s), you could do
ForEach-Object -Process {
$obj = [ordered]@{
VM = $_
}
$vm = Get-VM -Name $_ -ErrorAction SilentlyContinue
if ($vm)
{
$obj.Add('VC', ([uri]$vm.ExtensionData.Client.ServiceUrl).Host)
}
else
{
$obj.Add('VC', 'VM not found')
}
New-Object PSObject -Property $obj
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, LucD. It saved manual effort for validating each vm from vc.
Thanks
vmk
LucD,
Can we validate those VM's which we are able to find running on which ESXi version? I mean VM's running on VC.
thanks
vmk
Sure, try like this
ForEach-Object -Process {
$obj = [ordered]@{
VM = $_
}
$vm = Get-VM -Name $_ -ErrorAction SilentlyContinue
if ($vm)
{
$obj.Add('VC', ([uri]$vm.ExtensionData.Client.ServiceUrl).Host)
$obj.Add('ESXVersion', "$($vm.VMHost.Version) $($vm.VMHost.Build)")
}
else
{
$obj.Add('VC', 'VM not found')
$obj.Add('ESXVersion', 'na')
}
New-Object PSObject -Property $obj
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference