VMware Cloud Community
MarkIveli
Contributor
Contributor
Jump to solution

Script to list all windows machines

Hi,

I'm not the best scripter so i am looking for some advice on how to list all windows servers in a folder/cluster. My goal is to exclude updating the vmtools on my linux servers in any folder specified and on the windows servers i want to suppress a restart.

So far i have this

get-folder "Updates" |get-vm | Update-Tools -NoReboot

So what do i need to add to return just the windows servers? Any help is greatly appreciated

Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can select to update the VMware tools on only the Windows guests in folder Updates with:

Get-Folder "Updates" | Get-VM | Where-Object {$_.Guest.OSFullName -like "*Windows*"} | Update-Tools -NoReboot 

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

Reply
0 Kudos
6 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can select to update the VMware tools on only the Windows guests in folder Updates with:

Get-Folder "Updates" | Get-VM | Where-Object {$_.Guest.OSFullName -like "*Windows*"} | Update-Tools -NoReboot 

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
MarkIveli
Contributor
Contributor
Jump to solution

Points awarded, for information and responsiveness.....

any advice on how to check which version of VMtools in running and then upgrade only these VM's.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can use an extra condition in the where-clause.

Get-Folder "Updates" | Get-VM | `
   Where-Object {$_.Guest.OSFullName -like "*Windows*" -and ($_ | Get-View).Summary.Guest.ToolsStatus -eq "toolsOld"} | `
   Update-Tools -NoReboot

____________

Blog: LucD notes

Twitter: lucd22


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

MarkIveli
Contributor
Contributor
Jump to solution

Thanks LucD, this is great.

Where can i go / what can i read to understand more about the options that can be used with these conditions. I can get my head around the very basic commands but as soon as i need to add some options i get lost.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

For the PowerCLI (and PowerShell) cmdlets, you can always do a Get-Help like

Get-Help Get-VM
Get-Help Get-VM -Full

For the managed objects (which you can access via the Get-View cmdlet), you can search in the VMware vSphere API Reference Documentation. But that is not an easy subject !

Study existing scripts and try to understand what is used.

There is also a lot of information in this Community.

And there are several blogs (including mine) where you can read up on using the SDK properties and methods.

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
wamatha
Contributor
Contributor
Jump to solution

How would I  modify this script to:

1. Generate a report of all Windows VM's with out of Date VMware Tools per Cluster, send to csv file?

2. Update VMware Tools per Cluster without rebooting

Thanks you

Reply
0 Kudos