Alex
asked on
Object issues with Powershell
Ok so,
I've got this code, it pulls the CSV file which is a file named the same as the group, the file contains the objects within the group. in this case, computer objects.
Now, this code kinda works, well, it doesn't I get the error
Add-ADGroupMember : Cannot find an object with identity: 'CS-Computername' under: 'DC=net,DC=Domainaccept,DC =co,DC=uk' .
At line:2 char:83
+ ... ForEach-Object {Add-ADGroupMember -Identity $Group -Members $_.name}}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~
+ CategoryInfo : ObjectNotFound: ('CS-Computername:ADPrinci pal) [Add-ADGroupMember], ADIdentityNotFoundExceptio n
+ FullyQualifiedErrorId : SetADGroupMember.ValidateM embersPara meter,Micr osoft.Acti veDirector y.Manageme nt.Command s.AddADGro upMember
I think this is because I'm trying to add a computer object, any ideas?
Thanks
Alex
I've got this code, it pulls the CSV file which is a file named the same as the group, the file contains the objects within the group. in this case, computer objects.
$groups = get-content "C:\JLBR\JLBR.txt"
Foreach ($group in $Groups) {Import-csv "C:\JLBR\$($group).csv" | ForEach-Object {Add-ADGroupMember -Identity $Group -Members $_.name}}
Now, this code kinda works, well, it doesn't I get the error
Add-ADGroupMember : Cannot find an object with identity: 'CS-Computername' under: 'DC=net,DC=Domainaccept,DC
At line:2 char:83
+ ... ForEach-Object {Add-ADGroupMember -Identity $Group -Members $_.name}}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ('CS-Computername:ADPrinci
+ FullyQualifiedErrorId : SetADGroupMember.ValidateM
I think this is because I'm trying to add a computer object, any ideas?
Thanks
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mate :D