User Profile
RobinMalik
Copper Contributor
Joined 5 years ago
User Widgets
Recent Discussions
Re: PowerShell: Get-Team unreliable / returning incomplete results
@Vadim I must have missed that in the documentation then, thanks! I believe my issue to be throttling related and the Get-Team cmdlet either by itself or with -MailNickName or -DisplayName won't trigger an exception that shows there is throttling happening. You can however demonstrate it by overloading the tenancy calling Get-Team multiple times until it starts showing a lower number or 0, and then running Get-Team -GroupId with a valid ID and if you do that *at the right moment* it'll throw an exception with error 429 in the result (which indicates throttling).7.6KViews1like0CommentsRe: PowerShell: Get-Team unreliable / returning incomplete results
Here is an example script which proves the problem when obtaining all Teams. I've had results between 4454 and 4457, in a tenancy where no Teams are being created or deleted currently. $LoopCount = 1 $Loops = 10 $WaitTimeSeconds = 400 do { if($AllTeams) { $PreviousLoopData = $AllTeams } Write-Output "Get-Team Attempt $LoopCount | $(Get-Date -Format 'yyyy-MM-dd-HH-mm-ss')" try { $AllTeams = Get-Team -ErrorAction Stop Write-Output "Total Teams Found: $($AllTeams.Count)" if($PreviousLoopData) { $Diffs = Compare-Object -ReferenceObject $PreviousLoopData -DifferenceObject $AllTeams -Property MailNickName $NewButNotReally = $Diffs | Where-Object { $_.SideIndicator -eq '=>' } | Select-Object -Expand MailNickName if($NewButNotReally) { Write-Output " - Comparison between previous loop and this loop suggests the following Teams have been CREATED: $($NewButNotReally -join ', ')" } $DeletedButNotReally = $Diffs | Where-Object { $_.SideIndicator -eq '<=' } | Select-Object -Expand MailNickName if($DeletedButNotReally) { Write-Output " - Comparison between previous loop and this loop suggests the following Teams have been DELETED: $($DeletedButNotReally -join ', ')" } } } catch { $_ } Start-Sleep -Seconds $WaitTimeSeconds $LoopCount++ } until ($LoopCount -ge 11) You'll see things like: "Comparison between previous loop and this loop suggests the following Teams have been DELETED: XXX, YYY" ... and then in the following loop when they reappear again: "Comparison between previous loop and this loop suggests the following Teams have been CREATED: XXX, YYY"7.9KViews0likes3CommentsPowerShell: Get-Team unreliable / returning incomplete results
Hi, We have multiple issues with the Get-Team cmdlet in the MicrosoftTeams module (v2.3.0). Like many organisations, we're programmatically creating Teams based on organisational data (e.g. one Team to support one Dept/Module/some other business unit). However, Get-Team often fails to return Teams that we have previously created (and do still exist in Microsoft-land). This makes the data untrustworthy and very difficult to deal with. This problem can surface in multiple ways: 1) Running "Get-Team" to retrieve all teams Results are often incomplete. When this happens, there are usually around 1-5 'missing' from what we expect, out of around 4000 Teams. 2) Running "Get-Team -MailNickName" to query for a specific Team. This will sometimes fail to find a Team. We can run a loop 100 times (with 3 second wait) and it fails to find the Team 100 times. The next day, the Team is found 100 times. Sometimes for example, it's found only 95 times out of 100. Under the hood, it's using the Graph API. Example of a Team that exists, has an associated UnifiedGroup with ResourceProvisioningOptions=Team): Get-Team -MailNickName 'thisisateam' -Verbose -Debug VERBOSE: Done performing authorization VERBOSE: Executing Get-Team for parameters GroupId: , User: , Archived: , Visibility: , DisplayName: , MailNickName: thisisateam DEBUG: Making an api call to the uri: https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&$top=20&$count=true&$search="mailNickname:thisisateam" DEBUG: Returning 0 teams VERBOSE: Retrieving groups list VERBOSE: Done retrieving groups, getting team properties VERBOSE: Done processing Get-Team Has anyone else experienced this? The other issue is that -MailNickName doesn't return unique results and instead defaults to some kind of wildcard match rather than making a wildcard search optional. This is a problem for efficiently querying for data but can be worked around (by inefficiently passing all results to Where-Object), but I don't want to detract too much from the more urgent problem of unreliable data being returned. Help much appreciated. Thank you.8.5KViews0likes10Comments
Recent Blog Articles
No content to show