I'm trying to automate the creation of a new Microsoft Teams team through Powershell. I'm quite far and the script I made creates a new team and the channels, the only problem I have is that every time I run the script I get this error, which is kind of logical, but I can't fix it. Can anybody help me?
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
I'm using a loop to go through the CSV file:
#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
}
