Hi..
This has to be an easy one for you guys...
How do I list all VMs EXCEPT for VMs which have TEST or *TST'' in their name?
Sorry if this is too simple.... but I suck at this
/Rubeck
Are we talking about the VM name or perhaps about the hostname of the OS inside the guest ?
Could you perhaps do a
Get-VM <...TEST...> | Select *
so we could see what is in the Name field ?
You have to of course change the <...TEST...> to a name of an actual VM in your environment.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this
Get-VM | Where {$_.Name -notlike "*TEST*" -or $_.Name -notlike "*TST*"}
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I would have thougt so too as this stuff makes sense.... but it dosn't work... All VMs are listed.
The query hits a VC 4.1...
/Rubeck
Are we talking about the VM name or perhaps about the hostname of the OS inside the guest ?
Could you perhaps do a
Get-VM <...TEST...> | Select *
so we could see what is in the Name field ?
You have to of course change the <...TEST...> to a name of an actual VM in your environment.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It is the VM name seen in the VC inventory... A simple Get-VM | Select * works just fine..
This is the full output of this command: (I've X'ed out the ESX host name)
PowerState : PoweredOn
Version : v7
Description :
Notes :
Guest : VMware.VimAutomation.ViCore.Impl.V1.VM.Guest.VMGuestImpl
NumCpu : 1
MemoryMB : 2048
HardDisks : {Hard disk 1}
NetworkAdapters : {Network adapter 1}
UsbDevices : {}
CDDrives : {CD/DVD Drive 1}
FloppyDrives : {Floppy drive 1}
Host : xxxx.xxxxxx.local
HostId : HostSystem-host-867
VMHostId : HostSystem-host-867
VMHost : xxxx.xxxxxx.local
VApp :
FolderId : Folder-group-v2612
Folder : Overvågning
ResourcePoolId : ResourcePool-resgroup-9
ResourcePool : Resources
PersistentId : 52d770cd-6982-4421-04b5-d495d6d109e7
UsedSpaceGB : 14,0966
ProvisionedSpaceGB : 42,00285
DatastoreIdList : {Datastore-datastore-23, Datastore-datastore-998}
HARestartPriority : ClusterRestartPriority
HAIsolationResponse : AsSpecifiedByCluster
DrsAutomationLevel : AsSpecifiedByCluster
VMSwapfilePolicy : Inherit
VMResourceConfiguration : VMware.VimAutomation.ViCore.Impl.V1.VM.VMResourceConfigurationImpl
CustomFields : {[Do Not Delete, ]}
ExtensionData : VMware.Vim.VirtualMachine
Id : VirtualMachine-vm-1345
Name : APMonitor
Uid : /VIServer=vsphere_reporter@vcsphere.appension.local:443/VirtualMachine=VirtualMachine-vm-1345/
/Rubeck
Oops, my mistake (I think).
The -or should have been an -and
Get-VM | Where {$_.Name -notlike "*TEST*" -and $_.Name -notlike "*TST*"}
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, LucD.. (Like alot of people around here I really appriciate your help)
I can't try this out until tomorrow, Im afraid but then I'll do an update...
/Rubeck
You were spot-on, LucD.... Thanks alot... all is good now..
Works as expected..
/Rubeck