The Microsoft Windows PowerShell script below will request the hostname of a server then provide it’s uptime using Event ID 6005.

<#
.SYNOPSIS
This script will request the hostname of a server then provide it’s uptime.
.DESCRIPTION
This script will request the hostname of a server then provide it’s uptime.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, November 11, 2018.
#>

#Request the hostname of the server
$HOSTNAME = Read-Host “What is the hostname of the server?”

#Provide the uptime of the server
Get-EventLog -Logname System -ComputerName $HOSTNAME | Where-Object {$_.EventID -EQ 6005} | Select-Object -First 1

#End of script