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
72,861 times
Add to favorites
Windows Update
E-mail Twitter Digg Facebook
Sign in to ask a question

  • 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
      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
      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.
  • Parameters not wprking
    4 Posts | Last post April 28, 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>
  • 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)
  • server 2012 and 2008 windows update and pending files not reporting correctly
    1 Posts | Last post August 18, 2016
    • So I found the script does not report correctly on pending file operations on some of my servers. Its shows it has pending operations but does not. Its does this because the server has not created the registry key because it has not been needed. I think the script should be adjusted to detect if the registry key exists or not. If it does not report false. right now it reports true regardless, because the script always returns a value of "[]"
      For the windows update on server 2012 I am not sure how to detect pending restarts for updates. It think though it actually needs to look in "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" and check the key RebootRequired since, and return that value.
      Can anyone confirm this?
      Can @brian adjust the script?
      I am still a powershell n00b
  • How to use output to reboot a server that has a reboot pending
    1 Posts | Last post May 20, 2016
    • Brian,
      Thanks for all of your work on this script.
      We use a the "shutdown" command in a .cmd file to reboot servers within application groups. I could probably do this with a .ps1 file, but just haven't needed to yet.
      That being said, I tried using your Get PendingReboot.ps1 script and was able to have it run successfully. See the following:
      Computer           : ABCDEF
      CBServicing        : True
      WindowsUpdate      : False
      CCMClientSDK       :
      PendComputerRename : False
      PendFileRename     : False
      PendFileRenVal     :
      RebootPending      : True
      Not being a scripting expert, I assume I would like to use some sort of "If, then" statements so that:
      If RebootPending is True, then the script will run the "shutdown" command again, come back online, check reboot status and then reboot again if necessary or complete the script and remain online.
      We currently use Heat (formerly Lumension) for patching, but are in the process of deploying SCCM. Perhaps at that point, all of this will be mute, but for now I'm dealing with the cards I'm dealt.
      I'm also in the process of becoming more Powershell proficient, but until then, perhaps somebody can direct me as to the code I should run either in a cmd or ps1 file.
      Thanks for any input as how I should continue!
1 - 10 of 60 Items