Creating groups
Create a global security group
- ADSI
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the target container $containerDN = "CN=Groups,DC=domain,DC=com" $container = $service.OpenObject("Adaxes://$containerDN", ` $null, $null, 0) # Create group [Softerra.Adaxes.Interop.Adsi.ADS_GROUP_TYPE_ENUM]$groupType = "ADS_GROUP_TYPE_GLOBAL_GROUP, ADS_GROUP_TYPE_SECURITY_ENABLED" $group = $container.Create("group","CN=New Group") $group.Put("groupType", [int]$groupType) $group.SetInfo()
- PowerShell
-
Import-Module Adaxes $containerDN = "CN=Groups,DC=domain,DC=com" New-AdmGroup -Name "New Group" -Path $containerDN ` -GroupCategory Security -GroupScope Global ` -Server "domain.com" -AdaxesService localhost
Create a local distribution group
- ADSI
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the target container $containerDN = "CN=Groups,DC=domain,DC=com" $container = $service.OpenObject("Adaxes://$containerDN", ` $null, $null, 0) # Create group [Softerra.Adaxes.Interop.Adsi.ADS_GROUP_TYPE_ENUM]$groupType = "ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP" $group = $container.Create("group","CN=New Group") $group.Put("groupType", [int]$groupType) $group.SetInfo()
- PowerShell
-
Import-Module Adaxes $containerDN = "CN=Groups,DC=domain,DC=com" New-AdmGroup -Name "New Group" -Path $containerDN ` -GroupCategory Distribution -GroupScope DomainLocal ` -Server "domain.com" -AdaxesService localhost
Create a Microsoft 365 group
- ADSI
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the target container $containerDN = "OU=Groups,DC=domain,DC=onmicrosoft,DC=com" $container = $service.OpenObject("Adaxes://$containerDN", ` $null, $null, 0) # Create group [Softerra.Adaxes.Interop.Adsi.AzureADGroupType]$groupType = "Microsoft365" $group = $container.Create("group","CN=New Group") $group.Put("adm-AzureGroupType", [int]$groupType) $group.SetInfo()
- PowerShell
-
Import-Module Adaxes $containerDN = "OU=Groups,DC=domain,DC=onmicrosoft,DC=com" New-AdmGroup -Name "New Group" -Path $containerDN ` -GroupCategory Microsoft365 ` -Server "domain.com" -AdaxesService localhost
See also
- Writing ADSI scripts
- Server-side scripting
- IADs
- IADsContainer
- IADsGroup
- New-AdmGroup
- Online script repository