Easy PowerShell AD Commands
-
Disable a user account:
Disable-ADAccount usernameEnable a user account"
Enable-ADAccount usernameUnlock a user account:
Unlock-ADAccount usernameDelete a user account:
Remove-ADUser usernameFind all empty groups:
Get-adgroup -filter * | where {-Not ($_ | get-adgroupmember)} | Select NameAdd a member to a group:
Add-adgroupmember “groupname” –usernameEnumerate the members of a group:
Get-ADGroupMember “groupname”See what groups a user account is a member of:
Get-aduser username -property Memberof | Select -ExpandProperty memberOfDisable a computer account:
Disable-ADAccount -Identity “computername“Find computers by type:
Get-ADComputer -Filter * -Properties OperatingSystem | Select OperatingSystem -unique | Sort OperatingSystemCreate an organizational unit:
New-ADOrganizationalUnit -Name OUname -Path “dc=domainname,dc=com”Create a computer account:
New-ADComputer -Name username -Path “ou=OUname,dc=DCname,dc=com”Create a user account:
New-ADUser -Name username -Path “ou=OUname,dc=DCname,dc=com” -
Also, in PowerShell, just type:
Get-Command -Module ActiveDirectoryWhich should list all available AD commands.
-
@scottalanmiller said in Easy PowerShell AD Commands:
New-ADUser -Name username -Path “ou=OUname,dc=DCname,dc=com”
Thanks, just added all that to my documentation for reference later
-
One that I love
Get-ADPrincipalGroupMembership -Identity SOMEUSERNAME | Select nameList all of the groups in which the user is a member.