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
(90)
114,658 times
Add to favorites
Windows Update
6/20/2016
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Invoke-WMIMethod hanging within script from SCCM check
    1 Posts | Last post June 26, 2018
    • I've been troubleshooting a problem when I call this script against a list of computers.  Out of 1800 workstations, I find that this call will indefinitely hang my PSScript for 1 to 4 computers I query.  I've tracked it down to the invoke-wmimethod call it makes to check if SCCM is pending a reboot.  I can only guess that this indefinite hanging has to do with how WMI behaves and not having a default timeout period
      
      Ideally, I would love to have this call timeout after a predefined number has been set but I've been a bit stumped as to how to achieve this.  I'm curious if anyone else has come across this problem and/or has solved this issue.
      
      Thanks!
  • garget group?
    1 Posts | Last post June 18, 2018
    • thanks for a Great script.
      How about pull the list of computer from a target group?
      
  • Condensing the report to only show true values
    3 Posts | Last post June 13, 2018
    • Hi Brian, 
      
      Great script! I've put this into a scheduled task that runs and e-mails a report out to some admins regarding the pending reboots for any servers in the environment. I was just wondering if we can make it so it only shows the values that are listed as True so i can shorten the e-mail that goes out to only include the ones they need to see?
      
      Here's what i am using:
      
      $smtpServer = "MAILSERVER"
      $smtpFrom = "RebootReport@domain.com"
      $smtpTo = "AdminsWhoCare@domain.com"
      
      Import-Module .\Get-PendingReboot.ps1
      $Reboots = Get-PendingReboot -ComputerName (Get-Content C:\Scripts\ServerList.txt) | Format-Table -AutoSize | Out-String
      
      
      
      
      #############################################
      #E-mail Reboot Report to Admins
      #############################################
      $messageSubject = "Currently Pending Server Reboots"
      $messageBody = @"
      $Reboots
      
      "@
      
      $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
      $smtp.Send($smtpFrom,$smtpTo,$messageSubject,$messageBody)
    • Hi MC Nunzio,
      thanks for sharing your mail report settings.
      do you know how i can achieve that the output-tabel in the mail is also formatted like on console output?
      thanks
      Markus
    • Hi MC Nunzio,
      
      I am also looking for the same solution.
      
      Did you get the answer/resolution from anybody?
      
      Thanks
      jignesh
  • How to filter servers only Rebootpending (TRUE)
    1 Posts | Last post June 13, 2018
    • Hi Brian,
      i need only servers which are pending for reboot only() as i used server.txt and has 100+ servers.
      
      Thanks
      Jignesh Kyada
  • Powershell returns nothing
    3 Posts | Last post May 17, 2018
    • I have test powershell and script does run. Currently, it returns nothing. No error. No output in $error. 
      
      I have file text file and system name to test with both return nothing.
      
    • I had the same issue, the posts from Brian C. White and Markus E. Kugler helped to get mine to work in Server 2008
    • I had the same issue, could someone advice how to run!? when try to run error showing not recognized command
      
      PS C:\> Get-PendingReboot -ComputerName vnhcmm0dhcp02
      Get-PendingReboot : The term 'Get-PendingReboot' is not recognized as the name of a cmdlet, function, script file, or
      operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
      again.
      At line:1 char:1
      + Get-PendingReboot -ComputerName vnhcmm0dhcp02
      + ~~~~~~~~~~~~~~~~~
          + CategoryInfo          : ObjectNotFound: (Get-PendingReboot:String) [], CommandNotFoundException
          + FullyQualifiedErrorId : CommandNotFoundException
  • wrong output
    2 Posts | Last post May 13, 2018
    • Hi Brian,
      
      Thank you very much for the great script! I added the "last reboot"-feature and the mail-feature (seen here in q&a).
      
      the script is running daily as a scheduled task from my sccm server.
      
      I run in one issue:
      
      the script returns me tons of servers that seem to wait for a reboot but they don't.
      
      when I check the server directly it shows me that the server is not pending for reboot:
      
      PS C:\SCRIPT> get-pendingreboot -computername cert01
      
      Computer           : CERT01
      LastReboot         : 29.12.2017 12:04:28
      CBServicing        : False
      WindowsUpdate      : False
      CCMClientSDK       : False
      PendComputerRename : False
      PendFileRename     : False
      PendFileRenVal     : 
      RebootPending      : False
      
      
      I think it is because of the "PendFileRenVal". So I removed the PendFileRename and PendFileRenVal from the script...
      
      
      	    ## Creating Custom PSObject and Select-Object Splat
      	    $SelectSplat = @{
      	        Property=(
      	            'Computer',
                      'LastReboot',
      	            'CBServicing',
      	            'WindowsUpdate',
      	            'CCMClientSDK',
      	            'PendComputerRename',
      	            'RebootPending'
      	        )}
      	    New-Object -TypeName PSObject -Property @{
      	        Computer=$WMI_OS.CSName
                  LastReboot=$lastreboot.lastbootuptime
      	        CBServicing=$CBSRebootPend
      	        WindowsUpdate=$WUAURebootReq
      	        CCMClientSDK=$SCCM
      	        PendComputerRename=$CompPendRen
      	        RebootPending=($CompPendRen -or $CBSRebootPend -or $WUAURebootReq -or $SCCM)
      	    } | Select-Object @SelectSplat
      
      
      ...but it does not change anything
      
      can you help me?
      
      Thank you very much!
      
      Best regards
      Markus
      
    • My understanding is that though the server is not showing that it requires a reboot, there is a file waiting to be renamed, which can only happen after a reboot. I inferred this after reading this post: 
      https://blogs.technet.microsoft.com/brad_rutkowski/2007/06/27/are-there-pending-operations-waiting-for-a-reboot/
  • downloading this script result in a blank 0KB file
    1 Posts | Last post May 09, 2018
    • downloading this script result in a blank 0KB file
      
      Is there an error perhaps?
  • added HTML-Mail and AD-Server-query
    1 Posts | Last post January 10, 2018
    • Hi *
      
      this is how I use it. Thanks to McNunzio and IT Billing for inspiration:
      
      [begin script]
      
      
      Import-Module .\Get-PendingReboot.ps1
      Import-Module ActiveDirectory
      
      $computers = Get-ADComputer -Filter * -Properties operatingsystem |Where operatingsystem -match 'server' |where {$_.enabled -ne $false} |Sort-Object name
      
      $Reboots = Get-PendingReboot -Computer $computers.Name |where {$_.RebootPending -eq $true}|select computer, LastReboot, CBServicing, WindowsUpdate, CCMClientSDK |ConvertTo-Html -Head $style
      
      
      
      #########################################
      #E-mail Reboot Report To IT-Deptartment #
      #########################################
      $style = "<style>BODY{font-family: Verdana; font-size: 10pt;}"
      $style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
      $style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
      $style = $style + "TD{border: 1px solid black; padding: 5px; }"
      $style = $style + "</style>"
      
      $smtpServer = "my-mailserver-fqdn"
      $smtpFrom = "RebootReport@company.com"
      $smtpTo = "it-dept@company.com"
      $messageSubject = "[info] Server pending reboots"
      
      $message = New-Object System.Net.Mail.MailMessage $smtpFrom, $smtpTo
      $message.Subject = $messageSubject
      $message.IsBodyHtml = $true
      $message.Body =@"
      <p style="$style">Servers waiting for a Reboot:</p>
      
      $Reboots
      "@
      
      $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
      $smtp.Send($message)
      
      [end script]
  • RebootPending
    1 Posts | Last post December 28, 2017
    • Hi Brian 
      
      I would like to thank you for your good effort .
      
      I run the Query with success but I got the following Columns , the RebootPending colums value is true for some servers which dont require reboot or at least not shown in SRV manager dashboard  ! .
      
      opposite WindowsUpdate all true require restart .
      
      could you please explain the reason .
       
      Computer	CBServicing	WindowsUpdate	CCMClientSDK	PendComputerRename	PendFileRename	PendFileRenVal	RebootPending
      
      
      Best regards 
      Sid 
  • 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? 
1 - 10 of 70 Items