わかりました、スクリプトに問題があります。おそらくかなり明らかですが、スクリプトは次のとおりです。スクリプトが壊れている理由として、スクリプトのレビューとフィードバックをいただければ幸いです。
## Script Startup
$Computers = Get-Content .\computers.txt
$Total = $Computers.length
$consoleObject = (Get-Host).UI.RawUI
## Set Variables
$Run = 0
$Successful = 0
# Checks to see if there is a log file already created. If so check number of successful computer ran against, if not, create the log file.
IF ( test-path .\~temp.txt ) {
$Log = Get-Content .\~temp.txt
ForEach ($LogLine in $Log) {
$LogCheck = $LogLine.ToString().Split(",")[2]
IF ( "$LogCheck" -eq "Successful" ) {
$Successful += 1
}
}
} ELSE {
add-content .\~temp.txt "Computer Name,Attempts,Last Attempt,Time,Date"
}
while ( "$Completed" -le "$total" ) {
$Run += 1
$Time = Get-Date
$consoleObject.WindowTitle = “Admin Check - $Successful Out Of $Total Successful `| Run`: $Run”
ForEach ($Computer in $Computers) {
IF ( Select-String .\~temp.txt -pattern "$Computer" -quiet ) {
$LogUpdate = Select-String .\~Temp.txt -pattern $Computer
$Attempts = $LogUpdate.ToString().Split(",")[1]
$Result = $LogUpdate.ToString().Split(",")[3]
} ELSE {
add-content .\~temp.txt "$Computer,0,Not Checked,Not Run Yet,Not Run Yet"
$Attempts = ""
$Result = ""
}
IF ( "$Result" -eq "Successful") {
write-output "$Computer Already Completed"
} ELSE {
IF ( test-connection $Computer -quiet ) {
# Command Here
$Successful += 1
$IsOn = "True"
} ELSE {
$IsOn = "False"
}
$Attempts += 1
}
( Get-Content .\~temp.txt ) | Foreach-Object {$_ -replace "$Computer,.*", ($Computer + "," + $Attempts + "," + $IsOn + "," + $Result + "," + $Time.ToShortTimeString() + "," + $Time.ToShortDateString())} | Set-Content .\~temp.txt
}
}
~temp.txt
Computer Name,Attempts,Last Attempt Result,Time,Date
52qkkgw-94210jv,11111111111111,False,,8:47 PM,10/27/2012
HELLBOMBS-PC,11111111111111111111111111111111111111111111111111111111111,True,,8:47 PM,10/27/2012
52qkkgw-94210dv,11111111111111111111111111111111111111111111111111111111,False,,8:46 PM,10/27/2012
現在の問題: - 成功が合計に等しい場合、実際には停止しません。- 結果と成功をチェックしないので、すべてのコンプを永遠にやり直し続けます。- Attempts タブは、最後の時間か何かに 1 を追加し続けるため、奇妙な連続した "1111" になります。おそらく、まだ気づいていないだけです。