Good afternoon,
I am very new to Powershell scripting and the below script is running in ISE, but not Powershell. I run both programs “As Administrator” and get the results I am looking for. When run in Powershell, it never finishes. Any assistance would be greatly appreciated!
$AccountLockOutEvent = Get-EventLog -LogName “Security” -InstanceID 4740 -Newest 1
$LockedAccount = $($AccountLockOutEvent.ReplacementStrings[0])
$AccountLockOutEventTime = $AccountLockOutEvent.TimeGenerated
$AccountLockOutEventMessage = $AccountLockOutEvent.Message
$messageParameters = @{
Subject = “Account Locked Out: $LockedAccount”
Body = “Account $LockedAccount was locked out on $AccountLockOutEventTime.`n`nEvent Details:`n`n$AccountLockOutEventMessage”
From = “test@test.com”
To = “test@test.com”
SmtpServer = “mail.test.com”
}
Send-MailMessage @messageParameters
I removed my email addresses and SmtpServer address.
Thanks in advance for all of your help!!
Bill