VMware Cloud Community
CRad14
Hot Shot
Hot Shot

Piping vm objects to wmi commands

I have a quick and probably simple question. I am definitely a powercli/powershell noob...just fyi

Anyway I am trying to pipe vms to  "get-wmiobject win32_computersystem" however I am getting different errors

the effect I am trying to achieve would be if I just did a

get-wmiobject win32_computersystem -computername server1

But obviously with more VMs

My latest and most successful line is

get-vm|%{get-wmiobject win32_computersystem -computername $_.name}

even going so far as to try

get-vm|?{$_.PowerState -eq "PoweredOn"}|%{get-wmiobject win32_computersystem -computername $_.name}

However with some of the returns being what I want I get several errors as well.

I am sure this is something simple and if someone could point me in the right direction I would greatly appreciate it

Thanks!!

Conrad www.vnoob.com | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! 🙂
0 Kudos
1 Reply
CRad14
Hot Shot
Hot Shot

Nvm I figured it out.

I needed reference the hostname, now the only errors I get seem to be from boxes without vmtools installed.

if anyone is curious

get-vm|get-vmguest|?{$_.State -eq "Running"}|%{get-wmiobject win32_computersystem -computername $_.hostname}

Conrad www.vnoob.com | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! 🙂
0 Kudos