通过PowerShell添加新团队时出现问题

通过PowerShell添加新团队时出现问题,powershell,microsoft-teams,Powershell,Microsoft Teams,我正在尝试通过Powershell自动创建新的Microsoft团队。我已经走得很远了,我制作的脚本创建了一个新的团队和频道,我唯一的问题是每次运行脚本时我都会遇到这个错误,这是合乎逻辑的,但我无法修复它。有人能帮我吗 New-Team : Cannot validate argument on parameter 'DisplayName'. The argument is null or empty. Provide an argument that is not null or empty

我正在尝试通过Powershell自动创建新的Microsoft团队。我已经走得很远了,我制作的脚本创建了一个新的团队和频道,我唯一的问题是每次运行脚本时我都会遇到这个错误,这是合乎逻辑的,但我无法修复它。有人能帮我吗

New-Team : Cannot validate argument on parameter 'DisplayName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At C:\Users\Microsoft Teams\NewTeamV2.ps1:10 char:39
+     $GroupID = (New-Team -DisplayName $d.TeamDisplayName -Template $d ...
+                                       ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Team], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.TeamsCmdlets.PowerShell.Custom.NewTeam
我正在使用循环遍历CSV文件:


仅对设置了团队名称的行调用
New Team
。对于以下行,
$groupID
保持不变,因此
New TeamChannel
将频道分配给与前一个频道相同的团队

让我知道这是否适合你

foreach($d in$data){
如果($d.TeamDisplayName){
$GroupID=(新团队-DisplayName$d.TeamDisplayName-Template$d.Template)。GroupID
}
新TeamChannel-GroupId$GroupId-DisplayName$d.ChannelDisplayName
}

是的,我希望同一团队有多个频道
#Connection
$cred = Get-StoredCredential -Target 'Teams'
Connect-MicrosoftTeams -Credential $cred

#Importeren of data
$data = Import-csv comma.csv

#Loop for creation of teams and channels
foreach ($d in $data) {
    $GroupID = (New-Team -DisplayName $d.TeamDisplayName -Template $d.Template).GroupID
    New-TeamChannel -GroupId $GroupID -DisplayName $d.ChannelDisplayName    
}