Created
June 16, 2016 03:26
-
-
Save srpomeroy/e2ab4909052330e346b88e858503f33d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
$Computer ='dc01.contoso.com', | |
$Minutes = -240 | |
) | |
if ($Minutes -ge 0) {$Minutes = 0 - $Minutes} | |
$SelectOuput = @( | |
@{n='ComputerName';e={$_.MachineName}}, | |
@{n='Time';e={$_.TimeCreated}}, | |
@{n='Domain';e={$_.Properties[5].Value}} | |
@{n='Account';e={$_.Properties[0].Value}} | |
@{n='Source';e={$_.Properties[1].Value}} | |
) | |
$Date = (Get-Date).AddMinutes($Minutes) | |
$Events = $null | |
$Events = Get-WinEvent -ComputerName $Computer -FilterHashTable @{ LogName = "Security"; StartTime = $Date; ID = 4740 } | Select-Object $SelectOuput | |
$Events |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment