VMware Cloud Community
Kevin_Hamilton
Contributor
Contributor
Jump to solution

script to return all VM's and Operating System info

Wondering if anyone could point me to a script available or the correct line to pull out the Operating System info associated against all the VM's in VC. I seem to have a load of scripts but none appear to give me that specific info. Any help appreciated.

Cheers

H

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That's because that line returns the GuestFamily.

Use the GuestId property to get the OS name as VI knows it.

$vms = get-vm | get-view
foreach($vm in $vms){
  write-host $vm.Name $vm.guest.GuestId
}

If you want the guest OS as reported by the (Windows) Os itself you can use the command from this thread .

PS: the end tag for doesn't need a backslash. Just place your code between two identical tags.

I find that ...... works best. Without the blanks of course.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Did you try the command in ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Kevin_Hamilton
Contributor
Contributor
Jump to solution

LucD, you must live on this site LOL. Thankfully for mewbies like me.

get-vm | %{get-view $_.ID} | %{write-host $_.Name $_.guest.GuestFamily}

Just tried that line and it returns all my VM's with WindowsGuest against them. Is there something I need to add in to specify the acutal OS type. I appreciate the help.

H

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That's because that line returns the GuestFamily.

Use the GuestId property to get the OS name as VI knows it.

$vms = get-vm | get-view
foreach($vm in $vms){
  write-host $vm.Name $vm.guest.GuestId
}

If you want the guest OS as reported by the (Windows) Os itself you can use the command from this thread .

PS: the end tag for doesn't need a backslash. Just place your code between two identical tags.

I find that ...... works best. Without the blanks of course.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kevin_Hamilton
Contributor
Contributor
Jump to solution

Thanks for the help much appreciated.

0 Kudos