Script repository

Delete Remote Desktop Services profile folder

Updated on: Jan 18, 2026, Views: 4126

Folders and profiles, User accounts

The script deletes the Remote Desktop Services profile of a user. To execute the script, create a business rule, scheduled task or custom command configured for the User object type.

# Get the Remote Desktop Services profile path.
$rdsProfilePath = $Context.TargetObject.TerminalServicesProfilePath
if($rdsProfilePath -eq $NULL)
{
    return
}

# Check whether the Remote Desktop Services profile folder exists.
if(!(Test-Path -Path $rdsProfilePath))
{
    $Context.LogMessage("Remote Desktop Services profile folder with path $rdsProfilePath does not exist.", "Error")
    return
}

# Delete Remote Desktop Services profile folder.
Remove-Item -Path $rdsProfilePath -Force -Recurse

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.