0
サービスのping、最後の再起動時間、およびサービスが実行されている場合は、保守後のデータウィンドウを返すスクリプトがあります。私の2番目のfor-eachは、私のスクリプトでは空白の戻り値のときはデータを返しません。2番目のFor-Eachはデータを返しません
#### Provide the computer name in $computername variable
$ServerName = (Get-Content -Path "\\Server\d$\Data\Admin\Scripts\MW
scripts\Primary.txt")
$ServerNameB = (Get-Content -Path "\\Server\d$\Data\Admin\Scripts\MW
scripts\Primarylessalt.txt")
##### Script Starts Here ######
foreach ($Server in $ServerName) {
if (test-Connection -ComputerName $Server -Count 2 -Quiet) {
write-Host "$Server is alive and Pinging " -ForegroundColor Green
} else
{ Write-Warning "$Server is dead and not pinging"
}
}
foreach ($Server in $ServerName) { (Get-Service -Name "Print Spooler" -Cn
$Server) | Select name,status,machinename}
foreach ($Server in $ServerNameB){Get-CimInstance -Cn $Server -ClassName
win32_operatingsystem | select csname,lastbootuptime}
Format-Table -AutoSize
Write-Host "Script is complete" -ForegroundColor Cyan
Read-Host "Press Enter to Exit"
########## end of script #######################
コードをフォーマットしてください。それは読みにくいです –