大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
目前成都创新互联已为1000+的企业提供了网站建设、域名、网络空间、成都网站托管、企业网站设计、裕华网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
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 -MemberEdPrice
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 specificOU (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 specificCity (example: City=NewYork)
Get ADUser -Filter {city - like "NewYork"} | FT
Listonly 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 specificDepartment (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 specificGroup 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 specificGroup (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