How to Use Import-CSV with a Parameter that takes an Array
Hi! I'm trying to create a lot of distribution groups using a CSV import, but one of my columns needs to be for Members i.e. an array. However, Import-CSV is pulling in that column and wrapping it as a String. Is there any way around that or a different way to accomplishment this? I do not want to create a new CSV for each group's membership. Here is what I'm trying: Import-Csv C:\groups.csv | foreach { New-DistributionGroup -Name $_.GroupName -Alias $_.GroupAlias -CopyOwnerToMember -ManagedBy $_.OwnerPrimarySMTP -Members $_.MembersPrimarySMTP -Type security } I have my CSV all set up but it does not like my column MembersPrimarySMTP. This is the message I get where it shows that it's pre-wrapping it in quotes instead of taking the field as is: Couldn't find object ""user1@sample.com","user2@sample.com"". Please make sure that it was spelled correctly or specify a different object. + CategoryInfo : NotSpecified: (0:Int32) [New-DistributionGroup], ManagementObjectNotFoundException + FullyQualifiedErrorId : E6320406,Microsoft.Exchange.Management.RecipientTasks.NewDistributionGroup Thank you for your assistance and feedback! Rachel
August 12th, 2010 10:29pm

Does this work? Import-Csv C:\groups.csv | foreach { New-DistributionGroup -Name $_.GroupName -Alias $_.GroupAlias -CopyOwnerToMember -ManagedBy $_.OwnerPrimarySMTP -Members $_.MembersPrimarySMTP.split(",") -Type security }[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2010 10:41pm

Yes, it does! Thank you so much!
August 12th, 2010 10:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics