Script repository

Check if user home folder is empty

Updated on: Jan 18, 2026, Views: 1347

Folders and profiles

The script returns $true if home folder of a user is empty. To execute the script, use the If PowerShell script returns true condition in a business rule, custom command or scheduled task configured for the User object type.

$homeFolderPath = "%homeDirectory%"
if ([System.String]::IsNullOrEMpty($homeFolderPath))
{
    $Context.ConditionIsMet = $False
    return
}
 
$directoryInfo = Get-ChildItem -Path $homeFolderPath | Measure-Object
$Context.ConditionIsMet = $directoryInfo.Count -eq 0

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.