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

Delete Remote Desktop Services profile folder

February 18, 2021 Views: 2834

This script deletes the Remote Desktop Services profile specified in the Remote Desctop Services Settings attribute of a user account. To delete a user's Remote Desctop Services profile as a part of a business rule, scheduled task, or custom command, you need to use the Run a program or PowerShell script action that executes the script.

Edit Remove
PowerShell
# 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("Incorrect Remote Desktop Services profile path: $rdsProfilePath", "Error")
    return
}
# Delete Remote Desktop Services profile
Remove-Item -Path $rdsProfilePath -Force -Recurse

Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers