I was pretty ok with the old Get-VMHostAdvancedConfiguration cmdlet but I'm now rewriting some scripts to to set/reset syslogs using the new commands. Can someone assist here as I don;t see where I'm going wrong:
$vmHosts = get-vmhost
foreach ($esxHost in $vmHosts)
{
Get-AdvancedSetting -Entity (Get-VMhost -Name $esxHost) -Name "Syslog.global.logDir" | Set-AdvancedSetting -Value $logHost -Confirm:$False
write-host "Setting LogHost for $esxHost to $logHost"
Get-AdvancedSetting -Entity (Get-VMhost -Name $esxHost) -Name "Syslog.global.defaultRotate" | Set-AdvancedSetting -Value $logRotate -Confirm:$false
write-host "Setting Log Rotation for $esxHost to $logRotate"
}
Couple of problems here:
- It prompts for confirmation to change the settings unless I put the confirm:$False switch in
- It doesn't actually change the settings even if I remove the Confirm switch and approve the change manually.
- Each setting outputs the following type to console:
Uid : /VIServer=domain\user@myvcenter:443/VMHost=HostSystem-host-236/AdvancedSetting=VMHostSetting-Syslog.global.defaultSize/
Value : 10240
Description :
Type : VMHost
Entity : ESXhostname.domain.mine
Id : VMHostSetting-Syslog.global.defaultSize
Name : Syslog.global.defaultSize
Client : VMware.VimAutomation.ViCore.Impl.V1.VimClient
I have the feeling I'm missing something simple?