
The Chairman has a new challenge to prepare his scripting warriors for the upcoming PowerShell Summit. The challenge is aimed at intermediate to advanced scripters. You are encouraged to fulfill as many of the requirements as you can.
The Chairman would like a tool that he can use to query a Windows-based server to discover the following information:
- When was a server last shutdown?
- When did the server start up again?
- How long was it down?
- What is the current uptime?
Naturally, the output should include the computer name. To show your scripting superiority, the output should also include the account that initiated the shutdown or reboot. The function should accept alternate credentials and be able to accept pipeline input for a list of server names.
As always, please submit links to your work in the comments.
I’ll be interested to see how people pull in the userid – it’s a GUID in the event log entries and could be translated differently depending on if the user is in AD, a local user, a system account, or an unexpected restart.
https://github.com/psdarwin/Public/blob/main/IronScripter/Get-LastBoot.ps1
https://github.com/syafae/PowerShell-Fun/blob/master/UpDown.ps1
https://github.com/tethylis/Public/blob/main/Powershell/Challenges/IronScripter/UpDown.ps1