Active Directory Dynamic User Groups with PowerShell

When managing consumer entry permissions to varied assets in an Active Directory area, an administrator might need to create dynamic AD consumer teams. Dynamic teams make it simpler for an administrator to grant permissions on file servers, shared folders, workstations, and so forth. Such a dynamic group ought to routinely add customers to the group or take away them from it relying on the consumer account properties within the area.

For instance, you need to routinely add customers from the particular OU to the safety group, or to create a gaggle that features all consumer accounts of the particular division (the Department discipline within the AD consumer properties), and so forth.

On-premise Active Directory doesn’t have built-in instruments for implementing dynamic safety teams. However, you’ll be able to create a PowerShell script to routinely choose customers from Active Directory by a sure criterion and add them to an current AD safety group (you’ll be able to ) or take away the accounts that now not meet the necessities. When any of the AD consumer attributes are modified, the script should routinely add or take away a consumer from the group.

To use dynamic AD teams, you should preserve the related fields of all area consumer accounts up-to-date (for instance, when , you should instantly specify the town, the division, the corporate, and so forth.).

  1. In Exchange Server there are Dynamic Distribution List teams which might be populated routinely primarily based on some consumer standards, like the worth within the Company/City discipline in AD, the OU a consumer belongs to, the Exchange server, on which a mailbox is positioned, or every other consumer attribute in Active Directory. However, dynamic distribution teams could also be used to create distribution, however not the safety teams;
  2. There are built-in dynamic teams in Azure AD. In this cloud listing you’ll be able to create completely different guidelines of dynamic membership within the safety or Office 365 teams.
  3. Partially the Dynamic Access Control (DAC) in Windows Server 2012 or later can be utilized to exchange some options of dynamic safety teams.

Suppose, you need to routinely add to the prevailing safety group all customers from a number of OUs having the worth ‘Sales’ within the Department discipline within the properties of the AD consumer. I’ve written the next PowerShell script (to run it, you could set up the Active Directory for Windows PowerShell Module; the cmdlet is used to get the consumer properties, and Add-ADGroupMember, Get-ADGroupMember and Remove-ADGroupMember are the cmdlets to .)

## Your AD area title
$ADDomain = 'dc=woshub,dc=com'
## Dynamic group title
$ADGroupname = 'EastSales'
## OU record to look customers
$ADOUs = @(
"OU=Users,OU=NewYork,$ADDomain",
"OU=Users,OU=Chicago,$ADDomain"
)
$customers = @()
# Searching customers within the specified OUs
foreach($OU in $ADOUs)
foreach($consumer in $customers)

## Make certain that every consumer within the group meets the choice standards. If not (moved to a different OU, modified the Department discipline), they should be faraway from the group
$members = Get-ADGroupMember -Identity $ADGroupname
foreach($member in $members)
Select-Object Department).division -notlike "Sales" )

PowerShell script: to automate Active Directory Dynamic group memberships
Run the script and ensure that all customers from the required OUs with ‘Sales’ within the Department discipline have been routinely added to the EastSales group. The customers who don’t match these standards are faraway from the group.
implementing Dynamic AD Security groups with powershell

You need to run the script manually, however it’s higher to run it commonly via a underneath the account that has permissions to handle customers and teams in AD. (It isn’t advisable to run the script underneath the area admin account, you need to to a standard consumer/admin accounts or a .)

You can use this PowerShell script as a framework of your individual guidelines of making dynamic consumer teams in AD.

Check Also

How to Clear RDP Connections History in Windows?

The built-in Windows Remote Desktop Connection (RDP) consumer (mstsc.exe) saves the distant pc title (or …

Leave a Reply

Your email address will not be published. Required fields are marked *