I'm trying to run several Powershell commands one after the other, but it seems like only first three work: "Write-host", "Connect-MicrosoftTeams" and "Import-Csv -Path "C:\Users\Desktop\smith.csv" | foreach{Add-TeamUser -GroupId XXX -user $_.email}"
My script:
Write-host "Login to Microosft teams";
#Import and connect to Microsoft Teams
Import-Module -Name 'MicrosoftTeams'
Connect-MicrosoftTeams
Import-Csv -Path "C:\Users\Desktop\smith.csv" | foreach{Add-TeamUser -GroupId XXX -user $_.email}
if ($?) {
Import-Csv -Path “C:\Users\Desktop\smith.csv” | foreach{Add-TeamChannelUser -GroupId XXX -DisplayName "XXX" -user $_.email}
}
if ($?) {
Write-host "Users have been added"
}
How does it work? What should I do to run few commands one after the other? Thanks for the help!