Skip to content

Instantly share code, notes, and snippets.

@h-otter
Last active August 29, 2015 14:24
Show Gist options
  • Save h-otter/6bf39dc3f5afa0d11f5d to your computer and use it in GitHub Desktop.
Save h-otter/6bf39dc3f5afa0d11f5d to your computer and use it in GitHub Desktop.
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