List all members of a group (example: Group=Experts)
Get-ADGroupMember Experts | Format-Table Name
All properties of a group (example: Group=IT)
Get-ADGroup IT -Properties *
List only Universal Security groups
Get-ADGroup –LDAPFilter "(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=-2147483640))"
List only Global Security groups
Get-ADGroup –LDAPFilter "(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=-2147483646))"
List only Domain Local Security groups
Get-ADGroup –LDAPFilter "(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=-2147483644))"
List all Group memberships for a user (example: User=EdPrice)
Get-ADAccountAuthorizationGroup EdPrice
Move a Group to another OU (example: Group=Experts, Old-OU=IT, New-OU=Service, Domain=Contoso.com)
Move-ADObject "CN=Experts,OU=IT,DC=Contoso,DC=com" -TargetPath "OU=Service,DC=Contoso,DC=com"
Add members to a group (example: Group=Experts, User=EdPrice)
Add-ADGroupmember Experts -Member EdPrice
Delete Group (example: Group=Experts)
Remove-ADGroup Experts
Delete a User from a Group (example: Group=Experts, User=EdPrice)
Remove-ADGroupMember Experts -Member EdPrice
Set Description for a Group (example: Group=JoinPC, Description=This group is allowed join PCs to Domain)
Set-ADGroup JoinPC -Description "This group is allowed join PCs to Domain"
Add Users from one Group to another Group (example: from Group1=DataUsers to Group2=SQLUsers)
Get-ADGroupMember DataUsers | Select sAMAccountName | ForEach { Add-ADGroupMember SQLUsers -Members $_.sAMAccountName }
Comparing two Groups to see the Group memberships (example: Group1=Administratorso, Group2=DNSAdmins)
Compare-Object ( Get-ADGroupMember Administrators) ( Get-ADGroupMember DNSAdmins) -IncludeEqual
All OUs in Domain
Get-ADOrganizationalUnit -Filter {Name -like *“} | FT Name, DistinguishedName -A
Create OU (example: OU=IT, Domain=Contoso.com)
New-ADOrganizationalUnit -Name IT -Path "DC=Contoso,DC=Com"
Contents of a specific OU (example: OU=IT, Domain=Contoso.com)
Get-ADObject -Filter {Name -Like "*"} -Searchbase "OU=IT,DC=Contoso,DC=Com"
Rename OU (example: Old-Name=IT, New-Name=Admin, Domain=Contoso.com)
Rename-ADObject "OU=IT,DC=Contoso,DC=Com" -NewName Admin
Delete OU including contents (example: OU=IT, Domain=Contoso.com)
Remove-ADOrganizationalUnit IT -Recursive
Delete user from specific OU (example: User=EdPrice, OU=IT, Domain=Contoso.com)
Remove-ADObject "CN=EdPrice,OU=IT,DC=Contoso,DC=Com"
Move all objects from one OU to another OU (example: Old-OU=IT, New-OU=Manager, Domain=Contoso.com)
Get-ADObject -Filter {Name -Like "*"} -Searchbase "OU=IT,DC=Contoso,DC=Com" -SearchScope OneLevel | Move-ADObject -TargetPath "OU=Manager,DC=Contoso,DC=Com"
List all User accounts in the Domain
Get-ADUser –Filter *
List all User accounts in a specific OU (example: OU=IT, Domain=Contoso.com)
Get-ADUser –Filter * -Searchbase "OU=IT,DC=Contoso,DC=Com" | FT
List all User accounts from specific City (example: City=NewYork)
Get ADUser -Filter {city - like "NewYork"} | FT
List only disabled User accounts in Domain
Search-ADAccount –AccountDisabled –Usersonly | FT Name
List all User accounts whose First Name is Ed
Get-ADUser –Filter {givenName –Like "Ed"} | FT
List all User accounts whose Last Name is Price
Get-ADUser –Filter {Surname –Like "Price"} | FT
List all User accounts from the specific Department (example: Department=Support)
Get-ADUser –Filter {Department –Like "Support"} | FT
List a User's Group memberships (example: User=Richard)
Get-ADPrincipalGroupMembership -Identity Richard
List all Users from specific Group and move Users to another OU (example: Group=People, Target OU=NewYork, Domain=Contoso.com)
Get-ADGroupMember People -Recursive | Move-ADObject –TargetPath "OU=NewYork,DC=Contoso,DC=Com"
Remove all users in an OU from a specific Group (example: Group=People, OU=NewYork, Domain=Contoso.com)
$Users = Get-ADUser -Filter * -Searchbase "OU=NewYork,DC=Contoso,DC=Com"
Remove-ADGroupMember -Identity People -Member $Users -Confirm:0
Here are two great article about Active Directory LDAP Syntax and Active Directory Characters to Escape:
Active Directory: Characters to Escape (Richard Mueller - MVP)
Active Directory: LDAP Syntax Filters (Richard Mueller - MVP)
Move (Transfering or Seizing) FSMO roles with AD-Powershell command to another Domain Controller
How To Revert Back or downgrade Windows Server 2008 R2 Forest and Domain functional Level
PowerShell Portal
Wiki: Portal of TechNet Wiki Portals
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。