Skip to main content
PowerShell

Using Powershell to Manage your Active Directory User Accounts

By September 30, 2013September 12th, 2022No Comments

I will not end my quest to enlighten you all of the power of the command line 🙂

Using Powershell 2 and the Active Directory Cmdlets that ship with the 2008 Remote Server Administration Tools, managing your AD Users becomes very easy without the need of third part modules. In this video we look at creating an OU, user, adding the user to a group and resetting the password. For completeness we reverse the process and delete the user and OU.

New-AdOrganizationalUnit -Name TAB -Path "dc=tup,dc-local"
New-ADUser -Name JDoe -GivenName John -Surname Doe -Enable $true -Path "ou=tab,dc=tup,dc-local" -AccountPassword (ConvertTo-SecureString -AsPlainText "Pa$$w0rd"
Add-ADGroupMember "Domain Admins" JDoe
Get-ADgroupMember "Domain Admins"
Set-ADAccountPassword JDoe -Reset
Remove-ADGroupMember "Domain Admins" JDoe
Remove-ADUser JDoe
Set-ADorganizationUnit "ou=tab,dc=tup,dc-local" -ProtectFromAccidentalDeletion $false
Remove-ADorganizationUnit "ou=tab,dc=tup,dc-local"