Get-LastReboot.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<#
.Synopsis Get-LastReboot scans the Event log of a local or remote computer for events with ID 1074. .DESCRIPTION Get-LastReboot scans the Event log of a local or remote computer for events with ID 1074. Created by: Jason Wasser Modified: 1/23/2015 .EXAMPLE Get-LastReboot Retrieves the reboot events from the local computer. .EXAMPLE Get-LastReboot -computername server1,computer03 Retrieves the reboot events from server1 and computer03. #> Function Get-LastReboot { [CmdletBinding()] [Alias()] [OutputType([int])] Param ( # Computer name(s) [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, Position=0)] [string[]]$ComputerName=$env:COMPUTERNAME, # Number of newest recent entries from the System log [Parameter(Mandatory=$false,Position=1)] [int]$Newest=1000 ) Begin { } Process { foreach ($Computer in $ComputerName) { Get-EventLog -LogName System -Newest $Newest -ComputerName $Computer | Where-Object {$_.eventid -eq '1074'} | Format-Table machinename, username, timegenerated -AutoSize } } End { } } |