Skip to content

Instantly share code, notes, and snippets.

@Purp1eW0lf
Created February 15, 2022 23:22
Show Gist options
  • Save Purp1eW0lf/475b3d6a2c8b2f15f0779407b3565442 to your computer and use it in GitHub Desktop.
Save Purp1eW0lf/475b3d6a2c8b2f15f0779407b3565442 to your computer and use it in GitHub Desktop.
#needs the SAMAccountName
$user = "afairfax";
Disable-ADAccount -Identity "$user" -whatif # confirm this is what you want
Disable-ADAccount -Identity "$user" -verbose
#check it's disabled. Will return false if it is disabled.
(Get-ADUser -Identity $user).enabled
#re-enable the account when you're ready
$user = "afairfax";
Enable-ADAccount -Identity "$user" -verbose
#If the machine is not connected to Active Directory, or the account is local, try this
Net user afairfax /active:no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment