Powershell script, get locked account from multiple Windows 2008 servers

Param(
[Parameter(Mandatory=$True)]
[string]$Username,

[Parameter(Mandatory=$False)]
[array]$Computers=@(“ad-server1”, “ad-server2”)
)

$Date = [DateTime]::Now.AddDays(-2)
Get-EventLog “Security” -after $Date -computer $Computers | Where-Object { $_.InstanceID -eq 4740 -or $_.InstanceID -eq 4625} | ? { $_.message -match $Username} | fl TimeGenerated, Message

Leave a Reply

Your email address will not be published. Required fields are marked *