Last active
August 29, 2015 14:24
-
-
Save h-otter/6bf39dc3f5afa0d11f5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteDisableUsersDirectory{ | |
[CmdletBinding()] | |
param( | |
[parameter( | |
position = 0, | |
mandatory = 0 | |
)] | |
[string] | |
$path | |
) | |
$disableUsers = get-aduser -Filter {Enabled -eq $false} | select SamAccountName # Getting Disable Users | |
for ($i = 0; $i -lt $enableUsers.length; $i++) | |
{ | |
$oldDirectory = Join-Path $path $disableUsers[$i].SamAccountName | |
Remove-Item $oldDirectory | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment