Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import-module ActiveDirectory
- $Date = [DateTime]::Today.AddDays(-30)
- get-adcomputer -searchbase “OU=ou,DC=organization,DC=com” -Properties LastLogonDate -filter {lastlogondate -lt $Date} | select name, lastlogondate | Export-Csv “full\path\to\destination.csv”
- Send-MailMessage -From email@noreply.com -to receiver@email.com -subject “AD Report – Computer Accounts +30 days without a logon ” -SmtpServer xxx.xxx.xxx.xxx -body “Reports are organized by OU. Please do not reply to this email” -Attachments “full\path\to\destination.csv"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement