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.
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