I am going to be changeing the port of our syslog server. I can accomplish this with the following:
Set-VMHostSysLogServer -SysLogServer 'x.x.x.x:xxx' -VMHost '*'
After I ran this I wanted to doublecheck that everything was done. WHen I run the following I only get the syslog server and port but not the name of the host. How can I get it to display name of the host as well? maybe even export to csv?
Get-VMHost | Get-VMHostSysLogServer
Thanks.
You should be able to do that with a calculated property
Get-VMHost | Select Name,@{N="Syslog server";E={Get-VMHostSysLogServer -VMHost $_}}
And to export the data to a CSV file, just use the pipeline
Get-VMHost | Select Name,@{N="Syslog server";E={Get-VMHostSysLogServer -VMHost $_}} |
Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You should be able to do that with a calculated property
Get-VMHost | Select Name,@{N="Syslog server";E={Get-VMHostSysLogServer -VMHost $_}}
And to export the data to a CSV file, just use the pipeline
Get-VMHost | Select Name,@{N="Syslog server";E={Get-VMHostSysLogServer -VMHost $_}} |
Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks.
I ran into an issue when setting the syslog server the way I was going about it. When I use the following script if I hit a host taht is not connected to vCenter the whole script stops working and give me an error, at least I think thats what is happening. here is what I am using and about half way through the following error comes up. do you have a better way to accomplish this? thanks.
Set-VMHostSysLogServer -SysLogServer '10.2.6.32:515' -VMHost '*'
Set-VMHostSysLogServer : 1/4/2012 10:26:59 AM Set-VMHostSysLogServer Object reference not set to an instance of an object.
At line:1 char:23
+ Set-VMHostSysLogServer <<<< -SysLogServer '10.2.6.32:515' -VMHost '*'
+ CategoryInfo : NotSpecified: (:) [Set-VMHostSysLogServer], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostSysLogServer
Try it this way
Get-VMHost | Set-VMHostSysLogServer -SysLogServer 1.1.1.1 -ErrorAction SilentlyContinue
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks.
I ended up doing it this way... proably a cleaner way to do it, but this worked.
$Hosts = Get-VMHost
ForEach ($Hostname in $Hosts)
{
Set-VMHostSysLogServer -SysLogServer 'x.x.x.x:xxx' -VMHost $Hostname
write "Syslog Server was changed on $Hostname"
}