Compare commits
2 Commits
779d2ad2dd
...
1c7fcdacdf
Author | SHA1 | Date | |
---|---|---|---|
1c7fcdacdf | |||
5d74bd4e21 |
@ -19,7 +19,9 @@ $Users = Get-ADUser -SearchBase "$UsersOU" -Filter * -Properties * `
|
||||
| select DisplayName,userPrincipalName,lastLogon,distinguishedName | % { $_.lastLogon = [DateTime]::FromFileTime($_.lastLogon); $_ }
|
||||
|
||||
# Disable the accounts
|
||||
$Users | Disable-ADAccount
|
||||
foreach ($User in $Users) {
|
||||
Disable-ADAccount -Identity $User.distinguishedName
|
||||
}
|
||||
|
||||
# Email a report
|
||||
if (($Users.distinguishedName).Count -gt 0) {
|
||||
@ -29,7 +31,8 @@ if (($Users.distinguishedName).Count -gt 0) {
|
||||
<ul>
|
||||
$($Users | % { "<li>$($_.DisplayName) <$($_.userPrincipalName)>, not logged in since $($_.lastLogon)</li>" })
|
||||
</ul><br/>
|
||||
<p>This email was sent automatically. Please do not reply.</p>
|
||||
<p>This email was sent automatically. Please do not reply.</p><br/>
|
||||
<p><pre>$($UsersOU) $(Get-Date)</pre></p>
|
||||
"@
|
||||
|
||||
Send-MailMessage -SmtpServer $SmtpServer -Port $SmtpPort -UseSsl -From $SmtpFrom -To $SmtpTo `
|
||||
|
Loading…
x
Reference in New Issue
Block a user