Here are some of the common PowerShell cmdlets for Active Directory (AD) with examples:
Get-ADUser: This cmdlet is used to retrieve information about a specific user or all users in an AD domain. Example:
Get-ADUser -Identity "John Doe"New-ADUser: This cmdlet is used to create a new user in an AD domain. Example:
New-ADUser -Name "Jane Doe" -GivenName "Jane" -Surname "Doe" -SamAccountName "jane.doe" -UserPrincipalName "jane.doe@contoso.com" -Path "CN=Users,DC=contoso,DC=com" -AccountPassword (ConvertTo-SecureString "P@ssword1" -AsPlainText -Force) -Enabled $TrueSet-ADUser: This cmdlet is used to modify an existing user in an AD domain. Example:
Set-ADUser -Identity "Jane Doe" -Description "Marketing Manager"Remove-ADUser: This cmdlet is used to delete a user in an AD domain. Example:
Remove-ADUser -Identity "Jane Doe" -Confirm:$FalseGet-ADGroup: This cmdlet is used to retrieve information about a specific group or all groups in an AD domain. Example:
Get-ADGroup -Filter * -SearchBase "CN=Users,DC=contoso,DC=com"New-ADGroup: This cmdlet is used to create a new group in an AD domain. Example:
New-ADGroup -Name "Marketing Team" -GroupCategory Security -GroupScope Global -Path "CN=Users,DC=contoso,DC=com"Set-ADGroup: This cmdlet is used to modify an existing group in an AD domain. Example:
Set-ADGroup -Identity "Marketing Team" -Description "Marketing Department Team"Remove-ADGroup: This cmdlet is used to delete a group in an AD domain. Example:
Remove-ADGroup -Identity "Marketing Team" -Confirm:$FalseAdd-ADGroupMember: This cmdlet is used to add a member to a group in an AD domain. Example:
Add-ADGroupMember -Identity "Marketing Team" -Members "Jane Doe"Remove-ADGroupMember: This cmdlet is used to remove a member from a group in an AD domain. Example:
Remove-ADGroupMember -Identity "Marketing Team" -Members "Jane Doe"
No comments:
Post a Comment