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.

Script Repository

Check if user home folder is empty

March 23, 2021 Views: 640

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
Leave a comment

Got questions?

Support Questions & Answers