Wednesday, 28 September 2011

Poweshell script to find out computers pending reboot

$computers = Get-Content "C:\computers.txt"
foreach ($computer in $computers)
{
   Try{
   $HKLM = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $computer)
   $string = $HKLM.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager").getvalue("PendingFileRenameOperations")}
   Catch{}
   if($string){
   Write-Host "Pending reboot for computer" $computer}

No comments:

Post a Comment