I wrote this powershell script to find out the last SQL Server Restart times from a batch of servers in an excel sheet and output the results in an excel. The script also takes care of unreachable servers and prints a message that it could not be connected.
Although this is a simple script, the idea behind this can extended further to fetch similar information from SQL Server as required.
The script picks up the list of servers from an excel sheet and outputs the results on the console along with an excel sheet. Progress messages are also displayed.
The script takes the below 4 parameters as described below
|-InputFilePath||Mandatory, No defaults||Provide the complete path on the drive of the excel sheet. Prerequisite for the input file is to have the first row of the excel as the column header.|
|-Sheet||Default = ‘Sheet1’||Provide the name of the sheet where the server details are located. If not specified, the default value "Sheet1" will be considered.|
|-Columnnumber||Default=1||Provide the column number in the excel sheet where the server names are specified.|
|-OutputFilePath||Mandatory, No defaults||Provide the folder path where the output CSV file needs to be saved. Hardcoded filename will be outputServerDetails.csv.|
The script is attached to this blog post. Please do share your comments/views/ideas on this script.