We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Create Remote Desktop Services profile folder

February 18, 2021 Views: 2996

Using Adaxes, you can specify a Remote Desktop Services profile folder path that is stored in the Remote Desktop Services Settings attribute of a user account. However, setting a folder path does not actually create a folder on the file system. This script will automatically create a Remote Desktop Services profile folder for a user at the path specified in by Remote Desktop Services Settings.

To use the script, you need to create a business rule triggered automatically once a new user is created or changed. For more information on how to automatically run a script once a new user is created, see Run PowerShell Script after Creating a User. Alternatively, you can schedule creation of the profile folders.

See Also: assigning Remote Desktop Services Settings automatically.
Edit Remove
PowerShell
$homeFolderPath = $Context.TargetObject.TerminalServicesHomeDirectory

try
{
    $homeFolder = New-Item -ItemType directory -Path $homeFolderPath -ErrorAction Stop
}
catch
{
    $Context.LogMessage($_.Exception.Message, "Error")
    return
}

# Grant user full control permissions for the folder
# Get user SID
$userSidBinary = $Context.TargetObject.Get("objectSid")
$userSid = New-Object System.Security.Principal.SecurityIdentifier($userSidBinary, 0)

# Update permissions for the folder
$homeFolderACL = Get-Acl $homeFolder
$acl = New-Object System.Security.AccessControl.FileSystemAccessRule($userSid,"FullControl","ContainerInherit,ObjectInherit","None","Allow")
$homeFolderACL.AddAccessRule($acl)
Set-Acl -path $homeFolder $homeFolderACL
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers