This PowerShell script retrieves the uptime of a list of servers and outputs the results to a CSV file. The script reads a list of server hostnames from a file named server.txt
(that you must create) and retrieves the uptime of each server using the Get-Uptime
cmdlet. The output is then written to a CSV file named output.csv
(you must create this), which includes the hostname, hours since last reboot, and online status for each server.
- Windows PowerShell 3.0 or higher
- A list of server hostnames in a text file named
server.txt
- Clone or download the repository to your local machine.
- Add the list of server hostnames to a text file named
server.txt
. Each server hostname should be on a separate line. - Open PowerShell and navigate to the directory where the script is located.
- Run the script using the following command:
.\server-uptime.ps1
- The output will be written to a CSV file named
output.csv
in the same directory as the script.
- If a server is offline or unreachable, the script will output a message indicating that the server is offline in the CSV file.
- The output file will be overwritten each time the script is run, so be sure to save a copy of the previous output if needed.
This project is licensed under the MIT License - see the LICENSE file for details.