VMware Cloud Community
gman7777
Contributor
Contributor
Jump to solution

Update VMWare tools using Power CLI :Select VMGuests

Hi Everyone,

I have the following   script to upgrade VMWare Tools without a reboot.

update-Tools -VM VNNx -Noreboot

However, I need to only update 200 (UAT) VMWare guests instead of my full prod environment.

can I use this script, and reference a text file to determine which guests I want to upgrade.

Or another script that would allow me to use a text file of VMGuests that I only wnat to ugrade.


Thanks for your help

Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

If you make a text file VMs.txt with on every line the name of a VM that you want to update, you can update the VMware Tools of all those VM's with:

Get-Content -Path VMs.txt | `
ForEach-Object { Update-Tools -VM $_ -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
4 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

If you make a text file VMs.txt with on every line the name of a VM that you want to update, you can update the VMware Tools of all those VM's with:

Get-Content -Path VMs.txt | `
ForEach-Object { Update-Tools -VM $_ -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
gman7777
Contributor
Contributor
Jump to solution

Thank Robert,

works like a charm

Reply
0 Kudos
Pregunta89
Contributor
Contributor
Jump to solution

I know this is an old post, but I seem to be having troubles. I am extremely new to powershell, so forgive me.

My code is nearly the same, minus the obvious. I am throwing an couple terminator errors. What am I missing?


Get-Content -C:\VM\VMs.txt | '
ForEach-Object {Update-Tools -VM $_}

In my VM text document, I have one servername and that's it. 


Error message received:
The string starting:
At C:\VM\test.ps1:1 char 30

+ Get-Content -C:\VM\VMs.txt |  <<<< '

is missing the terminator: '.

At C:\VM\text.ps1:2 char:48

+ForEach-Object [Update-tools -VM $_} <<<<

      +CategoryInfo          : ParserError: (

Foreach-Objec...M $_}:String) [], ParseException

     + Fully QualifiedErrorId : TerminatorExpectedAtEndOfString

Any help would be great, thanks!

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The last character in the first line needs to be the back tick ` instead of the single quote '.

The minus sign before the path should not be there.

Get-Content C:\VM\VMs.txt | `

ForEach-Object {Update-Tools -VM $_}

Regards, Robert

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