Script Repository

Check if user home folder is empty

March 23, 2021

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.

Edit Remove
$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

Comments ( 0 )
No results found.
Leave a comment