Peter_Channing
Contributor
Contributor

Scripting question...

I'm sure this question has been asking a hundred times but I cant seem to find the answer so here we go...I'd like to see if anyone has a script (powershell?) already put together that will disable the screen saver on all the virtual machines registered to our vCenter server.

Has anyone come accross this before?

Any help would be appreciated.

Thanks.

0 Kudos
2 Replies
halr9000
Commander
Commander

Actually, not heard that one before. Smiley Happy

If you have PowerShell on all of your guests, then check out Invoke-VMScript. But that is besides the point, as I'd actually recommend you do this with a Group Policy. That would be a much more effective and in the long run, comprehensive, way to make workstation changes like this.






[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
yboychev
Hot Shot
Hot Shot

I agree with Hal that Group Policy is the better solution. But if you are still interested in a VITK script here you go:

As Hal mentioned Invoke-VmScript is the cmdlet that will do the trick. To use that cmdlet there are some certain prerequisits(those are not that much) which are well explained here: http://communities.vmware.com/message/1162125#1162125.

You will also need a windows commandline tool that can disable the screensaver. I found one called: flipss.exe available at: http://www.howtogeek.com/howto/windows-vista/create-shortcut-icon-to-disable-enable-the-screensaver/

So the script that should do what you are looking for looks something like this:

Note: If you dont have common accounts with same credentials for all esx hosts and respectively for all guest Os's then you should modify the script to handle this

$vmHostUserName = "hostAccount"

$vmHostPassword = "pass"

$guestOsUserName = "guestAccount"

$guestOsPassword = "pass"

Connect-VIServer -Server 192.168.0.132 -User Admin -Password pass

Get-Vm | Invoke-VmScript -ScriptText "C:\MyFiles\flipss.exe /off" -HostUser $vmHostUserName -HostPassword $vmHostPassword -GuestUser $guestOsUserName -GuestPassword $guestOsPAssword

Hope this helps,

Yavor

0 Kudos