I am trying to create a new distribution group from one CSV using the following code.
Import-Csv -Path C:\Users\Lenovo\Desktop\CIS\script\csv.csv | ForEach { New-DistributionGroup -Name $_.name -Members $_.members }
and my CSV has the following data.
name members
ITDepartment divyesh@xyz.com,milan.ramani@xyz.com
but when I run the above command it always gives me the below error.
Couldn't find object "divyesh@xyz.com,milan.ramani@xyz.com". Please make sure that it was spelled correctly or specify a different object.
+ CategoryInfo : NotSpecified: (:) [New-DistributionGroup], ManagementObjectNotFoundException
+ FullyQualifiedErrorId : [Server=AM6PR08MB4279,RequestId=4dc85b89-0791-4a2b-9409-beaf728789aa,TimeStamp=19-09-2022 14:31:12] [FailureCategory=Cmdlet-ManagementObjectNotFoundEx
ception] 10D55A27,Microsoft.Exchange.Management.RecipientTasks.NewDistributionGroup
+ PSComputerName : outlook.office365.com
I don't where am I doing wrong here.