Answered by:
Changing the Remote Desktop Profile Path with Powershell

Question
-
I am making a PowerShell script for automating user creation in the company I work in, but I have a problem.
How can I set the "Remote Desktop Services Profile Path" through Powershell? I can set all the other attributes I needed through SET-ADUser, but I couldn't find any -command to change the Remote Profile Path.
Is this even possible?
Thursday, July 15, 2010 8:46 AM
Answers
-
Hi,
Please try the following command to set TerminalServicesProfilePath attribute:
$user = [ADSI] "LDAP://CN=Username,OU=OUname,DC=DomainName,DC=com"
$user.psbase.Invokeset("terminalservicesprofilepath","\\server\share\user")
$user.setinfo()Thanks
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked as answer by Mervyn Zhang Friday, July 16, 2010 4:00 AM
Friday, July 16, 2010 4:00 AM
All replies
-
I haven't been able to play with Microsoft's AD cmdlets much, but one way to accomplish this is with Quest's cmdlets:
$user = Get-QADUser username $user.TsProfilePath = '\\server\share' $user.CommitChanges()
You could try something like this with the MS cmdlets:
$user = Get-ADUser -Identity "username" $user.TSProfilePath = "\\server\share" Set-ADUser -Instance $user
Thursday, July 15, 2010 11:58 AM -
I hoped I was able to do it with Microsofts AD cmdlets, anyone else know if it is possible with Microsofts? Or do I have to download Quest's cmdlets?Thursday, July 15, 2010 12:13 PM
-
-
I hoped I was able to do it with Microsofts AD cmdlets, anyone else know if it is possible with Microsofts? Or do I have to download Quest's cmdlets?
Look at some of the examples here: http://technet.microsoft.com/en-us/library/ee617215.aspx
Thursday, July 15, 2010 1:00 PM -
I hoped I was able to do it with Microsofts AD cmdlets, anyone else know if it is possible with Microsofts? Or do I have to download Quest's cmdlets?
Look at some of the examples here: http://technet.microsoft.com/en-us/library/ee617215.aspx
I have looked through that, I use Set-ADUser to add the home dir and logon script path, but I can't find any way to change the remote desktop profile path with it, and I don't want to install Quest's cmdlets if I don't have to.
I just can't understand why MS would give us a way to change every aspect of a AD user except the Remote Desktop Services page.
Thursday, July 15, 2010 1:07 PM -
From the Set-ADUser help: "Property values that are not associated with cmdlet parameters can be modified by using the Add, Replace, Clear and Remove parameters."
I would try something like this if the second example I gave doesn't work:
set-aduser -Identity "username" -replace @{TsProfilePath="\\server\share"}
Thursday, July 15, 2010 1:26 PM -
Thanks JHofferle, -replace worked to change all the attributes, but I still can't change the TS Profile Path. I found out through ADSI edit that it is saved under the Attrib called: "userParameters", but all the data seems to be crypted. I find "CtxWFProfilePath" inside it, but all after that is just showing up as chines characters.
Got any sugestions?
All other attributes seems normal, but the userParameters is crypted for some reason
Thursday, July 15, 2010 6:54 PM -
Hi,
Please try the following command to set TerminalServicesProfilePath attribute:
$user = [ADSI] "LDAP://CN=Username,OU=OUname,DC=DomainName,DC=com"
$user.psbase.Invokeset("terminalservicesprofilepath","\\server\share\user")
$user.setinfo()Thanks
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked as answer by Mervyn Zhang Friday, July 16, 2010 4:00 AM
Friday, July 16, 2010 4:00 AM -
Hi,
Please try the following command to set TerminalServicesProfilePath attribute:
$user = [ADSI] "LDAP://CN=Username,OU=OUname,DC=DomainName,DC=com"
$user.psbase.Invokeset("terminalservicesprofilepath","\\server\share\user")
$user.setinfo()Thanks
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.Friday, July 16, 2010 6:38 AM -
Glad to hear the suggestions worked. If you have more questions in the future, you’re welcomed to this forum.Thanks.
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.Monday, July 19, 2010 2:54 AM -
How do you set the Remote Desktop Profile Path for ALL users in a specific OU?
What would the syntax be if the users was located in a sub OU under another main OU
Tuesday, April 17, 2012 1:29 PM -
If you want to know the background behind why Set-ADUser doesn't work for Remote Desktop Services Profile properties and why Mervyn Zhang's answer works, then take a read of http://blogs.technet.com/b/heyscriptingguy/archive/2008/10/23/how-can-i-edit-terminal-server-profiles-for-users-in-active-directory.aspxWednesday, March 12, 2014 9:50 PM
-
From the Set-ADUser help: "Property values that are not associated with cmdlet parameters can be modified by using the Add, Replace, Clear and Remove parameters."
I would try something like this if the second example I gave doesn't work:
set-aduser -Identity "username" -replace @{TsProfilePath="\\server\share"}
set-aduser pshrestha -replace@{terminalservicesprofilepath="\\charleskendall\network\Profiles\Tsprofiles\pshrestha"}
Ran the above command, but got this error
Set-ADUser : The server failed to process the filter. At line:1 char:11 + set-aduser <<<< pshrestha -replace @{terminalservicesprofilepath="\\charleskendall\network\Profiles\Tsprofiles\pshrestha"} + CategoryInfo : NotSpecified: (pshrestha:ADUser) [Set-ADUser], ADException + FullyQualifiedErrorId : The server failed to process the filter.,Microsoft.ActiveDirectory.Management.Commands.SetADUser
I tried "TSProfilepath" & "terminalservicesprofilepath", both get the same error.
There seems to be another problem with the syntax in your one line solution.
Life is dangerous, no one has ever survived. So enjoy!
Tuesday, January 13, 2015 1:12 PM -
The Quest powershell Set-QADUser did this job for you easily :).
ie:
set-Qaduser -Identity "user" -TSProfilePath \\server\Profiles$\userID
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
- Proposed as answer by Wilson Jia Thursday, August 13, 2015 3:55 AM
Thursday, August 13, 2015 3:54 AM -
Please start you own topic with your question as this one has been answered and closed.
\_(ツ)_/
Monday, December 28, 2015 1:28 PM -
Here are a few functions I've created based on the findings in this Blog posting that may prove useful to others.
This first function Gathers all Remote Desktop Services Profile Paths in Active Directory for reporting use.
Function Get-ADUserProfiles { [cmdletbinding()] Param ( [parameter(ValueFromPipeline)] [Microsoft.ActiveDirectory.Management.ADUser]$Identity ) Process { $ADUser = Get-ADUser $Identity -Properties * | select -ExpandProperty disting* $ADUser = [ADSI]”LDAP://$ADUser” $ADUserProfile = New-Object -TypeName PSObject $ADUserProfile | Add-Member -MemberType NoteProperty -Name Username -Value $($ADUser.sAMAccountName) $ADUserProfile | Add-Member -MemberType NoteProperty -Name GUID -Value $($ADUser.GUID) $ADUserProfile | Add-Member -MemberType NoteProperty -Name DisplayName -Value $($ADUser.displayName) $ADUserProfile | Add-Member -MemberType NoteProperty -Name ProfilePath -Value $($ADUser.ProfilePath) try{$terminalservicesprofilepath = $ADUser.psbase.InvokeGet(“terminalservicesprofilepath”)} catch {$terminalservicesprofilepath = $null} $ADUserProfile | Add-Member -MemberType NoteProperty -Name RDSProfilePath -Value $terminalservicesprofilepath try{$allowlogon = $ADUser.psbase.InvokeGet(‘allowlogon’)} catch {$allowlogon = "Not Configured"} $ADUserProfile | Add-Member -MemberType NoteProperty -Name RDSAllowLogon -Value $allowlogon Return $ADUserProfile } }
$report = Get-ADUser -filter * | Get-ADUserProfiles
This second function will allow you to pipe output from your first gather function into it to process like this:
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.Function Set-ADUserRDSProfilePath { [cmdletbinding()] Param ( [parameter(ValueFromPipeline)] [Microsoft.ActiveDirectory.Management.ADUser]$Identity, [string]$RDSProfilePath ) Process { $ADUser = Get-ADUser $Identity -Properties * | select -ExpandProperty disting* $ADUser = [ADSI]”LDAP://$ADUser” $ADUser.psbase.Invokeset("terminalservicesprofilepath",$RDSProfilePath) $ADUser.setinfo() Return $ADUserProfile } } # Runs through and removes any RDS paths. It's configured so you can can change a path
#too and with a little modification you could base this by AD group membership. ForEach ($User in $($report |? {$_.RDSProfilePath -like "\\*"})) {
Get-ADUser $User.Username | Set-ADUserRDSProfilePath -RDSProfilePath $null
}
- Edited by Aquaus Thursday, October 5, 2017 9:41 PM
Thursday, October 5, 2017 6:06 PM -
Try coding it like this:
Function Get-ADUserProfiles{ Param ( [parameter(ValueFromPipeline)] [Microsoft.ActiveDirectory.Management.ADUser]$Identity ) Process { $ad = Get-ADUser $Identity -Properties DisplayName, ProfilePath $user = [ADSI]$aduser.Path $aduser = $ad | Select-Object SamAccountName, objectGUID, DisplayName, ProfilePath, allowlogon, terminalservicesprofilepath $aduser.terminalservicesprofilepath = try { $user.psbase.InvokeGet('terminalservicesprofilepath') } catch { 'n/a' } $aduser.allowlogon = try { $user.psbase.InvokeGet('allowlogon') } catch { 'Not Configured' } $aduser } }
The second function will not work in a pipeline.
\_(ツ)_/
- Edited by jrv Thursday, October 5, 2017 7:39 PM
Thursday, October 5, 2017 7:37 PM