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.

2 Comments

  1. Jay

    This script will through an error if user has not been configured with TerminalServicesProfilePath so I suggest below

    [array]$listofall = $null
    $list = Get-ADUser -Filter *
    foreach($dn in $list) {
    $t=”LDAP://“+$dn.DistinguishedName
    $user=[adsi]$t
    If ($User.AllowLogon -eq 1) {
    [array]$listofall += $user.psbase.invokeget(“TerminalServicesProfilePath“)
    }
    Else{
    [array]$listofall +=”Not Configured”
    }
    }
    $listofall | out-file c:\temp\tsprofiles.txt

  2. Andy

    Hi Eric!

    I was searching for hours to get a solution to build an array with the combination to use psbase.invokeset.

    Your article helped me to find a solution!

    THANKS!!
    Andy

Leave a Reply

Your email address will not be published. Required fields are marked *