I need to check for a list of VMs\Templates, which ones are templates. Is there a way to do that - powercli way?
An alternative
$names = Get-Content names.txt
$namesRegEx = $names -Join '|'
Get-View -ViewType VirtualMachine -Filter @{"Name"=$namesRegEx} |
Select Name,@{N="Template";E={$_.Config.Template}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There are 2 cmdlets, Get-VM and Get-Template.
If you suppress the errors you could use those. For example
$names = Get-Content names.txt
$vms = Get-VM -Name $names -ErrorAction SIlentlyContinue
$templates = Get-Template -Name $names -ErrorAction SilentlyContinue
Or do you mean something else ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
An alternative
$names = Get-Content names.txt
$namesRegEx = $names -Join '|'
Get-View -ViewType VirtualMachine -Filter @{"Name"=$namesRegEx} |
Select Name,@{N="Template";E={$_.Config.Template}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am using this, but its not helping -
$TEMPLATE = (get-Template $VM_NAME).Name
If ($TEMPLATE -eq $VM_Name)
{$CHK = "TEMPLATE"}
One more thing, When I m taking $cells.item($i,8) = (Get-VM $INPUT_IP|Select PowerState) , its thowing "0" for Powered OFF VMs.
Did you try any of the 2 sample script I gave ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I havent tried it yet.But I need something to check one server one time.
Can you convert this for my need -
Get
-View
-ViewType
VirtualMachine
-Property
Name
-Filter
@{
"Config.Template"
=
"true"
}
Not sure waht you mean with "one server", is that 1 vCenter or 1 ESXi server ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
One VM\template at a time.
I'm afraid I still don't get what exactly you want here.
Do you want to enter a name and then check if it's a VM or a template ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference