Get AD user Properties across the forest

#get all AD users in forest with name like v- and status is enable

$allusers = (get-adforest).domains| %{get-aduser -filter {SamAccountName -like “v-*” -and Enabled -eq $true} -Properties EMployeeNumber -Server $psitem}

# get same account name and employenumber and destinguishname and saved to csv file
$allusers | ?{$PSItem.EmployeeNumber -eq $null} | select SamAccountName,EmployeeNumber,DistinguishedName,@{l=”Domain”;e={($PSItem.DistinguishedName -split “,DC=”)[1..4] -join “.”}} | Export-Csv c:\temp\employnumber.csv -NoTypeInformation

4 Comments

  1. I do agree with all of the ideas you’ve presented in your post. They’re very convincing and will certainly work. Still, the posts are too short for beginners. Could you please extend them a bit from next time? Thanks for the post.

Leave a Reply

Your email address will not be published.