Get-PendingReboot - Query Computer(s) For Pending Reboot State

This function gets the pending reboot status on a local or remote computer. Now supports SCCM 2012 Clients.

 
 
 
 
 
4.5 Star
(83)
75,163 times
Add to favorites
Windows Update
6/20/2016
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • For workgroup join/leave how we will detect?
    1 Posts | Last post November 08, 2017
    • this script doesn't work for workgroup join/leave any suggestion how we can detect this? 
  • Can you add the -Credential option?
    3 Posts | Last post November 07, 2017
    • Brian -- would it be possible to add the ability to use the standard -Credential parameter, such that I could issue a "Get-PendingReboot servername -Credential (Get-Credential)" command for servers that won't accept my standard credential?  In our environment, that would be workgroup servers, domain controllers, etc.
    • modify function like that:
      param(
      	[Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
      	[Alias("CN","Computer")]
      	[String[]]$ComputerName="$env:COMPUTERNAME",
          [Parameter(Position=1,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
          [Alias("credential")]
       	[Management.Automation.PSCredential]$Credentials=$env:Credentials,
      	[String]$ErrorLog    
      	)
      .
      .
      $WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber, CSName -ComputerName $Computer -Credential $credentials -ErrorAction Stop
      
      $WMI_Reg = Get-WmiObject -List -Namespace "root\default" -ComputerName $Computer -Credential $credentials| Where-Object {$_.Name -eq "StdRegProv"}
      
      
    • Thank you povreshellcoder, worked perfectly! :)
  • Parameters not wprking
    5 Posts | Last post November 02, 2017
    • Hi, I can run this locally and it reports correctly. I however cannot add the -computername parameter. After typing the script and beginning to type "-comp" and then attempting to tab over it will not even bring up the -computername parameter.
      
      Even if I use the following command:
      
      $Servers = Get-Content C:\servers.txt
      .\Get-PendingReboot -ComputerName $Servers | Export-Csv C:\PendingRebootReport.csv -NoTypeInformation
      
      The output will only be the local system. Its almost like something was updated that will not let me call up the -computername parameter.
      
      Any thoughts?
    • Wow this seems to cool...
    • Good afternoon, did you solve the fault with the parameter ComputerName?
    • Hi Alan, the script is designed to be dot sourced, meaning it will need to be loaded in your current session by typing a period plus a space in front of the path to the script, i.e.:
      
      PS C:\> . C:\Scripts\Get-PendingReboot.ps1
      PS C:\> Get-PendingReboot -ComputerName <ComputerName>
    • One way around the dot-sourcing issue is to add the function to a module and import it.  I have several modules I import in my profile, and I added this script to the ServerAdmin module that gets imported every time I open PS.
      
  • Multiple Updates and reboot reporting
    1 Posts | Last post August 04, 2017
    • Morning! lol 
      
      Hey Brian, Is there a way via Reg/WMI that you can query if a SCCM update push is complete before reporting that a reboot is required in the event of multiple updates being installed that could require a reboot? Im researching it but didnt know if you knew off the top of your head. I didnt want to run a script and run into the issue of it detecting a reboot is needed for an update that was part of the push while other updates were still being installed as part of that push.
  • Export-Csv options
    2 Posts | Last post July 06, 2017
    • Hello, 
      This script has helped me a lot. Thank you.
      
      I have a question about nameing my .csv file. When I run the script I need the output file name to be different every time. My script is as follows:
      
      Import-Module .\Get-PendingReboot.ps1
      $Computers = Get-Content c:\scripts\EnabledComputers.txt
      Get-PendingReboot -Computer $Computers | Export-Csv C:\scripts\6_19_17PendingRebootReport.csv -NoTypeInformation
      
      Is it possible to create a variable to name the export file with the current date so I do not overwrite any other export file?
      
      Thank you again for the time and script help. I am fairly new to the PowerShell world, but learning as fast as I can. 
    • Try setting a variable to the date and time - and then name your CSV using the variable.
      
      $csvFile = get-date -Format dd-MM-yyyyTHH.mm.ss
      Import-Module .\Get-PendingReboot.ps1
      $Computers = Get-Content c:\scripts\EnabledComputers.txt
      Get-PendingReboot -Computer $Computers | Export-Csv C:\scripts\$csvFile.csv -NoTypeInformation
      
      
      You might have to play around with quotations to get it to work.  Good luck!
  • Not seeing result
    2 Posts | Last post June 26, 2017
    • Each time I run the script, ( .\Get-PendingReboot.ps1 -computername <computername>. I am not getting any result where I expect to see result. I am testing this on a server where I know there is a pending reboot. I checked to see if function is loaded and I do see it when I run Get-ChildItem function:*. I have domain admin rights on the box and I RDP to the server and running the script locally. Any help would be appreciated 
      
      Powershell version:
      Name                           Value
      ----                           -----
      PSVersion                      5.0.10586.117
      PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
      BuildVersion                   10.0.10586.117
      CLRVersion                     4.0.30319.42000
      WSManStackVersion              3.0
      PSRemotingProtocolVersion      2.3
      SerializationVersion           1.1.0.1
      
      caption        : Microsoft Windows Server 2008 R2 Standard
      OSArchitecture : 64-bit
      Version        : 6.1.7601
      BuildNumber    : 7601
      
      
      
    • I fixed my own problem. Forgot to load it into session.
  • Windows 10 ?
    1 Posts | Last post June 02, 2017
    • I notice Windows 10 is not listed as supported.  Since MS wants to world to go to W10 is it possible to verify it works on Windows 10 ?
  • Thank you
    2 Posts | Last post May 24, 2017
    • Thank you for making this script and publish it. We always trying to improve patch compliance and this script helps us analyze pending reboot issues. Not just that they are in pending reboot, but what component put them there.
    • Thanks Anders for the feedback, it's great to hear how the script is benefiting people.
  • Great Script but having one minor issue
    1 Posts | Last post April 28, 2017
    • Great Script.. It works locally on my system once the function is C:\Scripts\Get-PendingReboot.ps1 then running GetPendingReboot -ComputerName MyComputerName
      
      But when I attempt to run with a servers list I created: C:\Scripts\Servers.txt
      
       $Servers = Get-Content C:\Scripts\Servers.txt
       Get-PendingReboot -Computer $Servers | Export-Csv C:\Scripts\PendingRebootReport.csv -NoTypeInformation
      
      WARNING: server1: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
      
      I am thinking Credentials on running the script just do not exactly know how to accomplish it.
      
      
  • Partially Verified script on Windows Server 2012 R2
    1 Posts | Last post October 27, 2016
    • 
      PS C:\Users\Administrator\Downloads> C:\Users\Administrator\Downloads\Get-PendingReboot.ps1
      
      
      Computer           : QA-2012R2-S1
      CBServicing        : True
      WindowsUpdate      : True
      CCMClientSDK       : 
      PendComputerRename : True
      PendFileRename     : False
      PendFileRenVal     : 
      RebootPending      : True
      
      
      ** there is no way to comment on the post other than to ask a question. (Not that i know of)
1 - 10 of 61 Items