Script Repository


Delete Remote Desktop Services profile folder

September 04, 2015
1151

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 )
No results found.
Leave a comment