Script repository

Create Remote Desktop Services profile folder

Updated on: Jan 18, 2026, Views: 5206

Folders and profiles, User accounts

The script creates a Remote Desktop Services profile folder for a user on the file system. To execute the script, use a buniness rule, scheduled task or custom command configured for the User object type.


$homeFolderPath = $Context.TargetObject.TerminalServicesHomeDirectory

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

# Get user SID.
$userSidBinary = $Context.TargetObject.Get("objectSid")
$userSid = New-Object System.Security.Principal.SecurityIdentifier($userSidBinary, 0)

# Grant user full control 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

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    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.