私はPowerShellを初めて使用します。www.powershell.comでいくつかの行を読みました。今、私は問題を解決するためにあなたの助けが必要です。ネットワーク内のクライアントからUUIDを読み取りたい。そのため、すべてのPCが保存されているドキュメント「pcs.txt」を作成しました。
$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がない場合は、次のPCに移動します。
手伝ってくれませんか。