Introduction 

In windows infrastructure we are doing some tasks on server which require downtime like patch installation, roles installation, uninstallation, etc...Due to business critical requirements you may postpone the reboot task, but it is recommended to reboot the server wherever it is essential.So I developed a script which captures the details of servers which requires reboot and delivers the report.This script will be very useful if your environment is having Patching with no reboot collection in SCCM.

Version 

Version 

Name 

Date Published  

Features 

0.1

Get-PendingReboot.ps1

27-Apr-19

 Initial version 

 

How to Run the Script?

Prerequisites 

Preliminary configuration Tasks 

If you are running the script without modifying the inputs make sure that you configure the script execution environment as below before you execute the script.

Step 1 :    Create a folder C:\Admin\ on the system where you are running the script.

 

Step 2 :    This script reads the input or the server list from the file named Servers.txt located at C:\Admin\ .Hence you need to create a text file with servers.txt under that folder and update the server list in text file. I attached the samples with its output. You can also modify the input location and file name as per your setting.

 

Step 3 :    Set the execution policy - Run the PowerShell with Elevated privilege and set execution policy as unrestricted using below command.

 

PowerShell
Edit|Remove
Set-ExecutionPolicy Unrestricted –Force
 

Step 4 :    Verify the execution policy status after running the above command by using

PowerShell
Edit|Remove
Get-ExecutionPolicy
 

Step 5 :    Download the script and save script at C:\Admin folder or any folders at your convenience.


Images showing Initial Setup


 

  

 


 

 

 

 

Execution Procedure 

To run the script right click on the script from the location where it is saved and Select option Run with PowerShell.

 

Example 1:


 

 

Execution Result


 

 

 

Script Explanation

If it requires reboot then the data will be pushed to RebootRequired.txt

If the server is down or in ping timeout state then or having DNS resolution issues then it will be directed to badservername.txt.

If the server doesn’t requires reboot then, it will be written to output file RebootNotRequired.txt

 

Attachment Details

 

Conclusion and Feedback

Let’s quickly recap the key points of this script, using this content you came to know how to effectively use this script for validating the windows services status for multiple computers, the initial configuration tasks which are required to run this script along with the way how this script is coded. Hope you enjoyed!

I appreciate if you rate the value of this script and leave the feedback with recommendations to improve it at Q&A session.

Acronyms

Item 

Details 

UI

User Interface 

.PS1

Windows PowerShell Cmdlet File

SCCM

System Center Configuration Manager

 

References

About Execution Policies - Microsoft Docs.