Find AD users using Profile Paths (roaming profiles)

Posted by robd on May 08, 2014
powershell / 1 Comment

So today due to a server migration I needed a list of all the users who have roaming profiles, found this useful Powershell script:

Please note you need to ammed this line of code to suite your site: “OU=VI2,OU=Students,OU=Users,OU=Monmouth School,DC=Monmouth,DC=local”

Get-ChildItem -Filter "(&(objectclass=user)(objectcategory=user)(profilepath=*))" `
 -Path Ad:\"OU=DEPARTMENT,OU=Users,OU=SITE,DC=DOMAIN,DC=local" -Recurse |             
foreach {             
 $user = [adsi]"LDAP://$($_.DistinguishedName)"            
 $user | select @{N="Name"; E={$}},             
 @{N="DistinguishedName"; E={$_.distinguishedname}},            
 @{N="ProfilePath"; E={$_.profilepath}}            
} | export-csv txt.csv  

Tags: , , , , , , ,