Skip to content

Instantly share code, notes, and snippets.

@srpomeroy
Created June 16, 2016 03:26
Show Gist options
  • Save srpomeroy/e2ab4909052330e346b88e858503f33d to your computer and use it in GitHub Desktop.
Save srpomeroy/e2ab4909052330e346b88e858503f33d to your computer and use it in GitHub Desktop.
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