VMware Cloud Community

invoke-vmscript to configure Guest setting

Pls help me in configuring the below setting inside the guest os.

$defaultwindowssettings :

these setting should be automated and applied to all the windows machines.

power options set to never

firewall allow inbound and outbound

remote connections allow

UAC disable

create new user 'testuser' and set password 'testpassword', set only- password never expires and uncheck remaining.

add administrator and testuser to administrators groups


these setting should be automated and applied to all the linux machines. using (invoke-vmscript)

Disable selinux,

disable networkmanager, firewall, firewalld, libvirtd, iptables

add new user 'linuxuser' user

add linuxuser to sudoers





$answerfile= 'C:\Users\vk185112\Desktop\answerfile.xlsx'

foreach($vmsautodeploy in Import-Excel $answerfile ){

if($vmsautodeploy.GuestOSType -eq 'windows'){

Invoke-VMScript -VM $vmsautodeploy.VMName -GuestUser $vmsautodeploy.UserName -GuestPassword $vmsautodeploy.Password -ScriptText $defaultwindowssettings -ScriptType Powershell


else {

Invoke-VMScript -VM $vmsautodeploy.VMName -GuestUser $vmsautodeploy.UserName -GuestPassword $vmsautodeploy.Password -ScriptText $defaultlinuxsettings -ScriptType Bash



Regards Vineeth.K
0 Kudos
1 Reply

That is again a long list, and in fact those are WIndows and Linux settings/cmds.

For the UAC you could try the following.

Note that you need to be an administrator to do this, and that guest OS needs to be restarted to activate the new setting.

$cmdSet = @'

Set-ItemProperty -Path “HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System” -Name “EnableLUA” -Value “0”


Invoke-VMScript -VM MyVM -ScriptText $cmdSet -ScriptType Powershell

Restart-VMGuest -VM MyVM -Confirm:$false

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

0 Kudos