Difference between revisions of "Active Directory (PowerShell)"
Jump to navigation
Jump to search
(→Getting Started: Added Credentials) |
(→Groups: Added "Copy Users From Existing Group") |
||
Line 104: | Line 104: | ||
$group = Get-ADGroup "Operations Supervisors" # Get the "Operations Supervisors" group | $group = Get-ADGroup "Operations Supervisors" # Get the "Operations Supervisors" group | ||
$groups = Get-ADGroup -Filter 'GroupCategory -eq "Security"' -SearchBase "OU=Groups,DC=DOMAIN,DC=COM" # Get all security groups in the Groups OU | $groups = Get-ADGroup -Filter 'GroupCategory -eq "Security"' -SearchBase "OU=Groups,DC=DOMAIN,DC=COM" # Get all security groups in the Groups OU | ||
</source> | |||
=== Copy Users From Existing Group === | |||
The script below copies users from an existing group and adds them to another group (existing users in the group are unaffected). | |||
<source lang="powershell"> | |||
$Src_Group = "Source Group Name" | |||
$Dst_Group = "Destination Group Name" | |||
$Users = Get-ADGroupMember $Src_Group | |||
Add-ADGroupMember -Identity $Dst_Group -Members $Users -Credential (Get-Credential) | |||
</source> | </source> | ||