Get all users with a roaming terminal service profile
Hi,
At some point it’s nice to know who has a custom roaming profile setting which points to an old profile server. This is easily done using powershell:
Get-ADUser -LdapFilter “(profilePath=*old_location_name_filter*)” -Properties profilePath | Select SamAccountName, profilePath | Format-Table -AutoSize
Great! And now for all the users with a custom setting for roaming terminal servers profile. Now this is where problems arise, open adsiedit and look at all of the attributes of a user who has a custom roaming terminal services profile. You won’t find them, but luckily there is way to access those settings,
[array]$listofall = $null
$list = Get-ADUser -Filter *
foreach($dn in $list) {
$t=”LDAP://“+$dn.DistinguishedName
$user=[adsi]$t
[array]$listofall += $user.psbase.invokeget(“TerminalServicesProfilePath“)
}
$listofall | out-file c:\temp\tsprofiles.txt
The key here is [adsi]LDAP://[DistinguishedNameUser].psbase.invokeget(“TerminalServicesSettingProperty”)
invokeget lets you read the values set for the user relating to terminal services settings. Not just the roaming profile setting. In same manner it’s possible to use invokeset to set these properties using the same syntax.
I hope you will find this useful, it saved me a lot of time.