<#
  Set Active Directory Users Terminal Services Profile Path Using PowerShell
  There is no remote desktop services profile path attribute, because TerminalServicesProfilePath is saved in the Active Directory user object's UserParameters attribute as a binary blob
  This snippet will find ADUsers that match $TSProfilePath_OLD and set their remote desktop services profile path to $TSProfilePath_NEW 
#>

# Need Active Directory Cmdlets
Import-Module ActiveDirectory

# Change TerminalServicesProfilePath only on users that are currently pointing to:
$TSProfilePath_OLD = '\\aserverthatdoesnotexist\fake_share$\whatever.man'

# New TerminalServicesProfilePath
$TSProfilePath_NEW = '\\newaserverthatdoesnotexist\newfake_share$\newwhatever.man'

# Find Them
$UsersToBeModified = Get-ADUser -filter * | select samaccountname, DistinguishedName, @{n="TSProfilePath";e={([adsi]("LDAP://" + $_.DistinguishedName)).psbase.InvokeGet("terminalservicesprofilepath")}} | ?{$_.TSProfilePath -eq $TSProfilePath_OLD}

#Modify Them
foreach($UserToBeModified in $UsersToBeModified){
	Write-Host ("Working on " + $UserToBeModified.samaccountname)
	$DirectoryEntry = [adsi]("LDAP://" + $UserToBeModified.DistinguishedName)
	$DirectoryEntry.psbase.invokeSet("TerminalServicesProfilePath",$TSProfilePath_NEW)
	$DirectoryEntry.setinfo()
}