In the final part of this series, I will look at dealing with the lastlogontimestamp attribute and easily outputting the data you have gathered to a file. Part 2 left us with : $domains = [System.DirectoryServices.ActiveDirectory.forest]::getcurrentforest().get_domains() $ObjectCategory = "user" $ObjectProplist = "name","samaccountname","whencreated" $LdapQuery = "(&(objectCategory=$ObjectCategory)(name=ad*))" foreach ($domain in $domains){ ($domain).name $LDAPdomain = $domain.GetDirectoryEntry() $Searcher = New-Object System.DirectoryServices.DirectorySearcher($LDAPdomain, $LdapQuery, $ObjectProplist,"subtree") $Searcher.pagesize = 1000 $Results = $Searcher.FindAll() foreach ($Object in $Results){ foreach ($prop in $ObjectProplist){ ...
Powershell for Active Directory