Creating computer accounts
The following code sample create a new computer account.
- 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 container $containerDN = "CN=Computers,DC=domain,DC=com" $container = $service.OpenObject("Adaxes://$containerDN", ` $null, $null, 0) # Create a new compuer object $computer = $container.Create("computer", "CN=NEWCOMPUTER") [Softerra.Adaxes.Interop.Adsi.PersistentObjects.ADS_USER_FLAG_ENUM]$accountOptions = "ADS_UF_WORKSTATION_TRUST_ACCOUNT, ADS_UF_PASSWD_NOTREQD" $computer.Put("userAccountControl", [int]$accountOptions) # Save the computer account to the directory $computer.SetInfo()
- PowerShell
-
Import-Module Adaxes $containerDN = "CN=Computers,DC=domain,DC=com" New-AdmComputer -Name "NEWCOMPUTER" -SamAccountName "NEWCOMPUTER" ` -Path $containerDN -Server "domain.com" -AdaxesService localhost