Created
February 15, 2022 23:22
-
-
Save Purp1eW0lf/475b3d6a2c8b2f15f0779407b3565442 to your computer and use it in GitHub Desktop.
This file contains 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
#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