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.
PowerShell
$homeFolderPath = "%homeDirectory%"
if ([System.String]::IsNullOrEMpty($homeFolderPath))
{
$Context.ConditionIsMet = $False
return # No folder path
}
$directoryInfo = Get-ChildItem -Path $homeFolderPath | Measure-Object
$Context.ConditionIsMet = $directoryInfo.Count -eq 0