Powershell计算机列表
我如何使用服务器列表来实现这一点 已尝试执行Powershell计算机列表,powershell,Powershell,我如何使用服务器列表来实现这一点 已尝试执行$ComputerList=gc,但似乎不起作用 用一台计算机就可以了 $Start = (Get-Date).AddMinutes(-120) $ComputerList = $env:ComputerName $Events = gc C:\Temp\ErrorCodes.txt # Getting all event logs Get-EventLog -AsString -ComputerName $Computername | ForEa
$ComputerList=gc
,但似乎不起作用
用一台计算机就可以了
$Start = (Get-Date).AddMinutes(-120)
$ComputerList = $env:ComputerName
$Events = gc C:\Temp\ErrorCodes.txt
# Getting all event logs
Get-EventLog -AsString -ComputerName $Computername |
ForEach-Object {
# write status info
Write-Progress -Activity "Checking Eventlogs on \\$ComputerName" -Status $_
# get event entries and add the name of the log this came from
Get-EventLog -LogName $_ -EntryType Error, Warning -After $Start -ComputerName $ComputerName -ErrorAction SilentlyContinue |
Add-Member NoteProperty EventLog $_ -PassThru | Where-Object {$Events -contains $_.eventid}
} |
# sort descending
Sort-Object -Property EventLog |
# select the properties for the report
Select-Object EventLog, EventID, TimeGenerated, EntryType, Source, Message
# output into grid view window
Out-GridView -Title "All Errors & Warnings from \\$Computername"
将其强制为数组。。否则,如果只有一项,它将作为字符串输入
$ComputerList=@(gcc:\folder\ComputerList.txt)