私の職場でほとんどすべてのPCをシャットダウンしたい(2日以上実行している場合) 私はスクリプト上で最後と今週仕事をしています。方法。リモートで複数のPCをシャットダウン
$days = -0
$date = (get-date).adddays($days)
$lastboot = (Get-WmiObject Win32_OperatingSystem).LastBootUpTime
$Computer = Get-ADComputer -SearchBase 'OU=______,OU=______,DC=______,DC=______' ` -Filter '*' | Select -EXP Name
$lastbootconverted = ([WMI]'').ConvertToDateTime($lastboot)
write-host $date
write-host $lastboot
write-host $lastbootconverted
if($date -gt $lastbootconverted)
{
write-host Need to reboot
(Stop-Computer -$Computer -Force)
}
else
{
write-host no need to reboot
}
私はそれを実行すると、それは「(例外HRESULT:0x800706BA)RPC-サーバーは利用できません。」 は言う しかし、私はちょうど代わりに「$コンピュータ」のPC名を置けば、それはシャット私が望むようにPCはダウンしている。このRPC-Serverエラーとは何ですか?あなたは、Get-ADComputerをテストするために
OUは= _____とDC = ______民間会社名です...
あなたが持っている - $コンピュータが、私はそうは思いません$コンピュータ –
@Taylorギブすべきではないということが、私はそれを試してみましたが、それは変更されませんでした。 – Gunter
$ computerの出力は何ですか? – BenH