我正在尝试通过使用CSV文件中的数据在Office 365中创建多个用户。我的代码如下:
#Enter a path to import the CSV file
$OfficeUsers = Import-Csv C:\Users\***\Desktop\AllUsers.csv
#For each entry (user) in the file path
foreach($User in $OfficeUsers)
{
#Assign the following values to the variables
#User
$DisplayName = $User.fullname
$FirstName = $User.firstname
$LastName = $User.lastname
$Username = $User.email
#UGroups
$Office_Groups = "Egg_Group", "Chicken_Group", "Soup_Group"
New-MsolUser `
-DisplayName $DisplayName `
-FirstName $FirstName `
-LastName $LastName `
-UserPrincipalName $Username `
Add-UnifiedGroupLinks `
-Identity $Office_Groups `
-LinkType Members `
-Links $Username
}
但是,我遇到以下错误,无法找出原因:
Cannot process argument transformation on parameter 'Identity'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.ArrayList" to type "Microsoft.Exchange.Configuration.Tasks.DistributionGroupIdParameter".
+ CategoryInfo : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember
+ PSComputerName : outlook.office365.com
任何指导将不胜感激。