{"id":6878,"date":"2023-04-28T04:21:15","date_gmt":"2023-04-28T04:21:15","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=6878"},"modified":"2023-06-12T04:42:17","modified_gmt":"2023-06-12T04:42:17","slug":"365-powershell-report-on-inactive-users-and-passwords-never-expire","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/365-powershell-report-on-inactive-users-and-passwords-never-expire","title":{"rendered":"Local AD Powershell Report on Inactive Users and Passwords Never Expire"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\">[Net.ServicePointManager]::SecurityProtocol = `\n    [Net.SecurityProtocolType]::Tls12 ;\n\n#365 User \n$emailusername = \"smtp@domaincom.com\"\n\n#password saved from previous ( https:\/\/pariswells.com\/blog\/research\/how-to-save-secure-string-in-powershell ) \n$encrypted = Get-Content C:\\scripts\\ScheduledTask\\securePassword.txt | ConvertTo-SecureString\n$credential = New-Object System.Management.Automation.PsCredential($emailusername, $encrypted)\n\n$inactive = Search-ADAccount -UsersOnly -AccountInactive -TimeSpan \"42\" | ?{$_.enabled -eq $True}  \n$inactive = $inactive.name | out-string\n\n\n$passwordnextexpire = get-aduser -filter * -properties Name, PasswordNeverExpires | where {$_.passwordNeverExpires -eq \"true\" } \n$passwordnextexpire = $passwordnextexpire.name | out-string\n\nSend-MailMessage -From $emailusername -To to@domain.com -Subject \"Inactive User and Password Never Expire\" -Body \"6 weeksInactive Users `n------------------------`n $inactive`n`n Password Never Expire `n------------------------`n $passwordnextexpire\" -SmtpServer smtp.office365.com -Credential $credential -Usessl -Port 587<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1206,952,2445,576],"class_list":["post-6878","post","type-post","status-publish","format-standard","hentry","category-research","tag-1206","tag-email","tag-inactive","tag-powershell"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=6878"}],"version-history":[{"count":3,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6878\/revisions"}],"predecessor-version":[{"id":7013,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6878\/revisions\/7013"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=6878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=6878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=6878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}