Need to create several groups on a daily basis so I decide to create a powershell script to do this.
Import-Csv “C:\Util\efaxgroups.csv” | ForEach-Object {
$gname = $.“Name”
$manager = $.“Manager”
$OU = $_.“OU”
new-adgroup -Name “$gname” -ManagedBy “manager” -Path “OU=$OU,DC=test,dc=edu” -Description “Provides users to Fax Service” -GroupScope Global -GroupCategory Security
}
the error
new-adgroup : Identity info provided in the extended attribute: ‘ManagedBy’ could not be resolved. Reason: ‘Cannot find an object with identity: ‘manager’ under: ‘DC=test,DC=edu’.’.
At line:7 char:1
- new-adgroup -Name “$gname” -ManagedBy “manager” -Path "OU=$OU,OU=TES …
-
- CategoryInfo : InvalidData: (CN=FDU-GSG-eFax…t,DC=fdu,dc=edu:String) [New-ADGroup], ADIdentityResolutionException
- FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityResolutionException,Microsoft.ActiveDirectory.Management.Commands.NewADGroup
When I run the command manually it works great.
new-adgroup -Name “Test-Group” -ManagedBy “testuser” -Path “OU=Test,OU=Security-Groups,DC=test,dc=edu” -Description “Provides users to Fax Service” -GroupScope Global -GroupCategory Security
The input file is a csv file
Name Manager OU
Any ideas on why the Manageby is not being substituted properly? I tried “” ‘’ no quotes
Thank you
Tom