How to get Import-CSV to work with Add-Adgroupmember
hello,
my goal to populate active directory global security group members contained in csv file.
i execute following:
$members = import-csv c:\groupmembers.csv
$members | foreach-object {add-adgroupmember -identity 'ad_group' -members $_}
these errors get:
add-adgroupmember : cannot bind parameter 'members'. cannot convert "@{a0100041=a62008}" value of t
ype "system.management.automation.pscustomobject" type "microsoft.activedirectory.management.adprinc
ipal".
@ line:1 char:78
+ $members | foreach-object {add-adgroupmember -identity 'ad_group' -members <<<< $_}
+ categoryinfo : invalidargument: (:) [add-adgroupmember], parameterbindingexception
+ fullyqualifiederrorid : cannotconvertargumentnomessage,microsoft.activedirectory.management.comm
ands.addadgroupmember
is saying import-csv produces object of type foreach-object cmdlet cant handle? in advance.
thanks help! sdedot
hi,
column header have in csv ? if havent try that:
$members = import-csv p:\test.csv -header group $members | foreach-object {add-adgroupmember -identity 'tg' -members $_.group}
if have header in file leave -header group , in foreach use $_.<name of header>
Windows Server > Windows PowerShell
Comments
Post a Comment