将服务器上的某些特定日志统一保存至XPS文件

<APACHost.CSV>
Hostname,IP,OSType
srv1,10.103.22.22,Win2003
srv2,10.103.22.37,Win2008
 
Import-Csv -Path F:chgpwdAPACHost.CSV | ForEach-Object {
    "**************" + $_.Hostname + "**************"
    if($_.OSType -eq 'Win2003') { Get-EventLog -ComputerName $_.hostname -LogName Security -InstanceId 538 -Newest 1 | fl * }
    else { Get-EventLog -ComputerName $_.hostname -LogName Security -InstanceId 5447 -Newest 1 | fl * }
} | Out-Printer -Name "Microsoft XPS Document Writer"
原文地址:https://www.cnblogs.com/IvanChen/p/4493763.html