Compare commits

...

2 Commits

@ -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) &lt;$($_.userPrincipalName)&gt;, 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 `