I have this script below (I got it from here) that adds syslog info to a vCenter server. It fails with the error below:
A server error occurred: 'com.vmware.vapi.std.errors.invalid_argument': The provided argument tcp is not valid. (Server error id: 'com.vmware.appliance.logging.forwarding.invalid.arg'). Check $Error[0].Exception.ServerError for more details.
At c:\Scripts\vcentersyslog.ps1:22 char:1
+ $log.set($cfglist)
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException
Can someone please help to get it to work so that I can run it towards one or more vCenter servers, and for it to output a message to show the vCenter server name, the previous syslog server entry, then the new syslog server entry? If this is not possible, could it at least display a "Success" or another descriptive message next to each result? If the output can also be in a CSV report format that would be very helpful. Thank you.
#This will prompt you to enter your credentials
$vCenterCredential = Get-Credential -Message "Enter the account for this vCenter" -ErrorAction SilentlyContinue;
#Provide vCenter server bane and connect to it
Connect-CisServer -Server vcenterserver -Credential $vCenterCredential | Out-Null
#Configure syslog on the vCenter server
$log = Get-CisService -name 'com.vmware.appliance.logging.forwarding'
$cfglist = [System.Collections.Generic.List[PSObject]]::new()
$spec = @{
hostname="syslogserver"
port=123
protocol="tcp"
}
$cfglist.add($spec)
$log.set($cfglist)
# To verify the setting
$log.get()
#Disconnect from the vCenter server
Disconnect-CisServer -Server vcenterserver -Confirm:$false
The protocol property is case-sensitive, should be uppercase.
$spec = @{
hostname = "syslogserver"
port = 123
protocol = "TCP"
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The protocol property is case-sensitive, should be uppercase.
$spec = @{
hostname = "syslogserver"
port = 123
protocol = "TCP"
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ah! That's it. Thanks LucD!