Hello,
I am having some trouble with a script I wrote a year or so ago for vSphere 5.1 hosts. Now I am looking to run it on vSphere 5.5 hosts and I am getting errors.
# Connection to the ESX Host to be configured #
$a = Read-Host "Please enter ESX FQDN:"
Connect-VIServer -Server "$a" -Credential(Get-Credential)
# Set the SYSLOG Directory #
$hostName = Get-VMHost
$hostName = $hostName.Name.Split(".")[0]
$logLocation = "[AVH-ESXLogs] " + $hostName
Set-AdvancedSetting Syslog.global.logDir -Value $logLocation
Disconnect-VIServer $a -Confirm:$false
When I run the script I get the following error:
Cannot bind parameter 'AdvancedSetting'. Cannot convert the "Syslog.global.logDir" value of type "System.String" to type "VMware.VimAutomation.ViCore.Types.V1.AdvancedSetting".
At :line:9 char:19
+ Set-AdvancedSetting <<<< Syslog.global.logDir -Value $logLocation
I am guessing it Is something stupid, I have been messing around with this script for a few hours and it is starting to all look the same.
Thanks for the help.
eric
You will have to do a Get-AdvancedSetting before, something like this
Get-AdvancedSetting -Entity $vmhost -Name Syslog.global.logDir | Set-AdvancedSetting -Value $logLocation
You get the current setting and then pipe it to the next cmdlet, which makes the change.
See also the examples on the Set-AdvancedSetting cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You will have to do a Get-AdvancedSetting before, something like this
Get-AdvancedSetting -Entity $vmhost -Name Syslog.global.logDir | Set-AdvancedSetting -Value $logLocation
You get the current setting and then pipe it to the next cmdlet, which makes the change.
See also the examples on the Set-AdvancedSetting cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok, I made the change and it is still erroring out:
# Set the SYSLOG Directory #
$hostName = Get-VMHost
$hostName = $hostName.Name.Split(".")[0]
$logLocation = "[AVH-ESXLogs] " + $hostName
Get-AdvancedSetting -Entity $hostname -Name Syslog.global.logDir | Set-AdvancedSetting -Value $logLocation
Disconnect-VIServer $a -Confirm:$false
thoughts?
And which error do you get ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am a complete moron... Fat fingered the DS name... :smileyblush:
everything works great...
thanks as always for the help.