Script repository
The scripts delete or purge a user’s profile folder. To execute the scripts, create a business rule, scheduled task or custom command configured for the User object type.
Script 1: Delete user profile folder
# Get profile folder path.
try
{
$profilePath = $Context.TargetObject.Get("profilePath")
}
catch
{
return
}
# Check whether the profile folder exists.
if(!(Test-Path -Path $profilePath))
{
$Context.LogMessage("Incorrect profile path: $profilePath", "Error")
return
}
# Delete the profile folder.
Remove-Item -Path $profilePath -Force -RecurseScript 2: Purge user profile folder
# Get profile folder path.
try
{
$profilePath = $Context.TargetObject.Get("profilePath")
}
catch
{
$Context.LogMessage("No profile path specified for the user", "Warning")
return
}
# Delete the contents of the profile folder.
$childItem = Get-ChildItem -Path $profilePath -Force
if($childItem -ne $NULL)
{
$childItem | Remove-Item -Force -Recurse
}
Comments 0
You must be signed in to comment.