Get Duplicate users in a forest
(Get-aduser -filter * -server Domainname:3268 | Group-Object -Property UserprincipalName | ?{$PSItem.Count -gt 1 -and $PSItem.Name -ne “”}).group |export-csv c:\temp\duplic.csv -NoTypeInformation
Knowledge is Power
(Get-aduser -filter * -server Domainname:3268 | Group-Object -Property UserprincipalName | ?{$PSItem.Count -gt 1 -and $PSItem.Name -ne “”}).group |export-csv c:\temp\duplic.csv -NoTypeInformation
$AllUSers = get-aduser -filter {SamAccountName -like “z*” -and Enabled -eq $true } -Properties Memberof,EmployeeNumber -Server <Domain name> | ?{$PSItem.DistinguishedName -notmatch “OU=Service Accounts”} $results = new-object System.Collections.ArrayList foreach($user in $AllSers){ $grps … Read More
foreach($d in (get-adforest).domains){$v = Measure-Command {get-addomaincontroller -Filter * -Server $d}Write-Output “Took $($v.TotalSeconds) to Enumerate DCS in $d “}