Could someone help me with a powershell script to update all our VDI machines to the latest PNtools?
What I'm looking for is the following:
A script that can be launched at night.
It should upgrade max. 10 virtual machines (or any number we specify).
It should only upgrade VM's that are turned off, or suspended, or running without someone logged in.
The steps would probably look like this:
Power on VM
uninstall PNtools
reboot
install PNtools
shutdown
Another problem is that I can't include a password to the powershell. You can specify a username to execute the script, but you have to type the password yourself. This way we can never automate this. Any tips?
I've included an updated script that will query for all VMs that do not have the current PNTools version installed and are currently Powered Down. If you look in the script you will see CurrentState = 1, which indicates that a machine is Powered Down.
If you have a text file of machines you could do something like:
This would queue up an uninstall and then an install for all the machines in the text file. The file would have to have one machine per line. If it is more convient to have a comma seperated list you could also do something like this:
I would also check by manually powering on a VM in the vWorkspace console that it does report a IP address. It might be a timing issue with the script or something else, for example the VMs really are not getting a IP address.
Here is an updated script that calls the Invoke-QVWComputerAction -Action PowerOn command. Then the script will wait for the machine to report an IPAddress. Once this happens it will begin the installation. Alternatively, I've included the below script using the text files I mentioned in previous posts.
It takes about 15 minutes to upgrade a client. To prevent users from logging in during the upgrade, the script disables the VM before the upgrade and enables it when it's done.
DELL-Adam D
15 Posts
638
0
Posted February 10th, 2011 14:00
Hey René,
Did you have a look at the blog post regarding this topic? If not have a gander at this.
If you still have questions after reading please let me know. As for the password issue you can do something like this:
Function Get-ConsoleCredential([String] $username, [String] $password)
{
New-Object Management.Automation.PSCredential $username, (ConvertTo-SecureString $password -AsPlainText -Force)
}
This will return a PScredential object with the proper username and password set.