我正在尝试从节点列表中获取 EventLog 系统;我正在使用 psexec 和 Get-EventLog。我想通过添加我想从文件中读取的 After 和 Before 参数来加快该过程。
这是在服务器上运行的一段代码:
#$Da = Pick-Date -testo "DATA INIZIO?"
#$Da | Out-File $localDir\GetEventLog.da.txt
#$Al = Pick-Date -testo "DATA FINE?"
#$Al | Out-File $localDir\GetEventLog.al.txt
foreach ($node in Get-Content $localDir\GetEventLog.input.txt)
{
net use N: $node\c$ $pwd /user:$node\administrator
mkdir N:\GetEventLog\
copy $localDir\GetEventLog.cmd N:\GetEventLog\
copy $localDir\GetEventLog.ps1 N:\GetEventLog\
# copy $localDir\GetEventLog.da.txt N:\GetEventLog\
# copy $localDir\GetEventLog.al.txt N:\GetEventLog\
psexec $node C:\GetEventLog\GetEventLog.cmd
copy N:\GetEventLog\System.* $localDir\
net use N: /delete
pause
}
这是在客户端上运行的:
$wrkDir = "c:\GetEventLog"
$filenameFileOutput = "$wrkDir\System." + $(hostname) + ".txt"
Get-EventLog System | Out-File -Width 200 $filenameFileOutput
我无法将 GetEventLog.da.txt 和 GetEventLog.al.txt 文件的内容作为参数传递给 Get-EventLog。
谢谢