我是新来的powershell。我在www.powershell.com上阅读了一些内容。现在我需要你的帮助来解决问题。我想从网络中的客户端读取UUID。因此我创建了一个存放所有PC的文件“pcs.txt”。Powershell超时两秒后
$pc = Get-Content pcs.txt #Read content of file
$cred = Get-Credential “domain\user”
for ($i=0; $i -lt $pc.length; $i++) {
$Result=test-connection -ComputerName $pc[$i] -Count 1 -Quiet
If ($Result -eq 'True')
{
$uuid = (Get-WmiObject Win32_ComputerSystemProduct -ComputerName $pc[$i] -Credential $cred).UUID
$Ausgabe=$pc[$i] + ';'+$uuid
$Ausgabe
}
else
{
$Ausgabe=$pc[$i] + '; UUID nicht erhalten'
$Ausgabe
}
}
首先我测试ping是否有效。当ping工作时,我尝试获取uuid。 有时候即使ping工作,我也不会得到uuid。所以我想编一个超时时间,这表示 - >当你在2秒后没有uuid时,进入下一台电脑。
你能帮助我吗?
的链接是巨大的。但我没有得到它的工作 Alwais它引发了一个异常连接0参数和获得0参数。 $ uuid =(Get-WmiCustom -computername $ pc [$ i] -namespace“root \ cimv2”-class Win32_ComputerSystemProduct -timeout 1).UUID –