VMware Cloud Community
vin01
Expert
Expert

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

$defaultlinuxsettings:

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

$defaultwindowssettings=@'

'@

$defaultlinuxsettings=@'

'@

$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
Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

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

Reply
0 Kudos