Get all Expired accounts
but they still exist in AD as well as Empty Groups which exist in AD.
Script for Empty Group:
Import-Module
activedirectory
Get-ADGroup -Filter * -Properties Members | where {-not $_.members} | select Name | Export-Csv C:\groups.csv –NoTypeInformation
Get-ADGroup -Filter * -Properties Members | where {-not $_.members} | select Name | Export-Csv C:\groups.csv –NoTypeInformation
Script for Expired IDs:
Import-Module
ActiveDirectory
Search-ADAccount -AccountExpired | select Name, samAccountName, ObjectClass, AccountExpirationDate, lastLogonDate | Export-Csv c:\Accounts.csv
Search-ADAccount -AccountExpired | select Name, samAccountName, ObjectClass, AccountExpirationDate, lastLogonDate | Export-Csv c:\Accounts.csv
Comments
Post a Comment