1

I'm getting pretty frustrated with Powershell and interacting with Teams etc. This is part of my script that has been working all week. Suddenly it is no longer returning the GroupID.

Connect-ExchangeOnline -UserPrincipalName user@domain.com

$team = New-Team -MailNickname $TeamName -displayname $TeamName -Visibility "private"

Write-Host "Team GUID: $team.GroupID" #This is empty

New-TeamChannel -GroupId $team.GroupId -DisplayName "2021 - 2022 Academic Year"

I of course get an error saying the GroupID is null.

Is this an issue with the code or something with Microsoft's end? I'm on the 2.5 version of the module (was the preview earlier)

boxdog
  • 7,894
  • 2
  • 18
  • 27
Nathan
  • 2,461
  • 4
  • 37
  • 48
  • According to the [documentation](https://learn.microsoft.com/en-us/powershell/module/teams/new-team?view=teams-ps), `New-Team` returns just the `GroupID`, not a whole 'team' object, so all you need to do is `$groupID = New-Team -MailNickname $TeamName -displayname $TeamName -Visibility "private"; Write-Host "Team GUID: $groupID"`. I don't have access to a system to check, but should be easy for you to see what `$team` contains in your current script. – boxdog Aug 20 '21 at 12:35
  • 1
    i went back to the 2.4.1-preview of the module and its now working. with 2.5 it doesn't. – Nathan Aug 20 '21 at 13:11
  • in 2.5 if i write the variable $groupID i get the following, not just the GUID. /teams('7e19563f-841e-4a60-97c8-4f8bd4fba55c')/operations('c5297a87-5df1-45af-a4fd-685ede8de2c9') – Nathan Aug 20 '21 at 13:24
  • Also in their documentation (example 3) it states i should still access the guid with $var.GroupID – Nathan Aug 20 '21 at 13:26
  • In the output from v2.5 is one of the GUIDs the one you need? If so, you could use a RegEx or similar technique to get just the part you need - not ideal, but would get you working until the next update that fixes this (if it's not deliberate). – boxdog Aug 20 '21 at 13:59
  • As an aside re the expandable string in your `Write-Host` call: In order to embed _expressions_ in an expandable string (`"..."`), you must enclose them in `$(...)`. Notably, this includes property and indexed access (e.g., `$($var.property)`, `$($var[0])`). Only variables _as a whole_ do not require this (e.g., `$var`, `$env:USERNAME`). See [this answer](https://stackoverflow.com/a/40445998/45375). – mklement0 Aug 20 '21 at 16:34
  • I have tried same faced no issue in MicrosoftTeams v2.5.0. I think mistakenly in question you have put `Connect-ExchangeOnline -UserPrincipalName user@domain.com` but it should be `Connect-MicrosoftTeams`. What error you are getting when creating channel, is it giving error as it is null and not creating any? Or can you specify specific error you are getting. – Hunaid Hanfee-MSFT Aug 24 '21 at 07:11
  • I saw `GroupID is null.` you are getting but it is working fine for me. You can check the content of variable directly by entering $variableName on PowerShell, can you confirm what's inside `$team`? Also is team getting created? – Hunaid Hanfee-MSFT Aug 24 '21 at 07:14
  • 1
    I tried today again just to make sure that it is working and faced same issue with v2.5.0. It seems like a bug to me. – Hunaid Hanfee-MSFT Aug 25 '21 at 07:20
  • There are two open pull requests for documentation to address this. One by myself to update the release notes to document this breaking change, and another to update the New-Team documentation to give an example of how to work with the new object that's returned by New-Team. Whether this is intentional or a bug, I don't know. – Robin Aug 25 '21 at 12:56

0 Answers0