Quantcast
Channel: Software Communities : Popular Discussions - ActiveRoles
Viewing all articles
Browse latest Browse all 1277

Dynamic Groups created by a script

$
0
0

Hi,

 

I grabbed a script create dynamic groups using Powershell from this forum and tweaked it to get the names of the groups from a file.The script works fine. I can see that it creates the dynamic group and adds the desired objects as its members. However, when I try to preview it(by going into membership Rules in the GUI), it errors out on the filter. On looking further I saw that the filter is missing a parenthesis at the end like this:

 

(extensionattribute1=247   <--- Note the missing parenthesis.

 

Any thoughts on why the paren is missing. The Dynamic group however works..it seems like there is an issue while ARS reads the filter into the GUI.

 

Thanks

Dipti

 

 

Script:

 

 

if ( (Get-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin Quest.ActiveRoles.ADManagement
}

Connect-QADService -Proxy

$GroupNameArray=Get-Content -path "D:\Scripts\CreateDynamicGroup\GroupName.txt"


$GroupsOU = 'OU=Sites,OU=Groups,OU=Admin,DC=mydomain,DC=com'

Foreach ($groupNameobj in $GroupNameArray) {

$splitinput = $groupNameobj.Split(";")
$groupname = $splitinput[0]
$ea1 = $splitinput[1]

$DN=(New-QADGroup -Name $groupName -SamAccountName $groupname -ParentContainer $GroupsOU).DN


$objGroup = [ADSI] "EDMS://$DN"

$objRuleCollection = $objGroup.MembershipRuleCollection

$rule1 = New-Object -ComObject "EDSIManagedUnitCondition"

$rule1.Base = "EDMS://DC=mydomain,DC=com"

$rule1.Filter = "(&(objectCategory=computer)(objectClass=computer)" + "(extensionattribute1="+$ea1+"))"

write-host $rule1.Filter

$rule1.Type=1

$objRuleCollection.Add($rule1)

$objGroup.SetInfo()

}


Viewing all articles
Browse latest Browse all 1277

Trending Articles