Powershell 检查文件中的计算机是否联机
我正在检查computers.txt文件中的计算机是否联机。我使用下面的推荐,但我想看到计算机名称旁边的真假决议这一点。有可能添加它吗Powershell 检查文件中的计算机是否联机,powershell,Powershell,我正在检查computers.txt文件中的计算机是否联机。我使用下面的推荐,但我想看到计算机名称旁边的真假决议这一点。有可能添加它吗 Test-Connection -BufferSize 32 -Count 1 -ComputerName (Get-Content C:\Temp\computers.txt) -Quiet | Out-GridView 为此,需要使用ForEach循环并输出具有所需属性的PSObject: Get-Content C:\Temp\computers.txt
Test-Connection -BufferSize 32 -Count 1 -ComputerName (Get-Content C:\Temp\computers.txt) -Quiet |
Out-GridView
为此,需要使用ForEach循环并输出具有所需属性的PSObject:
Get-Content C:\Temp\computers.txt | ForEach-Object {
[PsCustomObject]@{
Computer = $_
IsOnline = Test-Connection -BufferSize 32 -Count 1 -ComputerName $_ -Quiet
}
} | Out-GridView
为此,需要使用ForEach循环并输出具有所需属性的PSObject:
Get-Content C:\Temp\computers.txt | ForEach-Object {
[PsCustomObject]@{
Computer = $_
IsOnline = Test-Connection -BufferSize 32 -Count 1 -ComputerName $_ -Quiet
}
} | Out-GridView
西奥回答的替代方案,使用语法: 优点:速度更快,即使在不支持
[pscustomobject]
缺点:笨拙的语法西奥回答的替代方案,使用语法: 优点:速度更快,即使在不支持
[pscustomobject]
缺点:语法笨拙