Closed skghq closed 8 months ago
How could you create Teams without a display name? A display name is required during creation. So, even if we would adjust the DSC resource to allow the export of Teams with a blank display name, we could not use it for importing it again.
@malauter I haven't a clue... but somehow it is in my tenant configuration...
@malauter Found the problem:
I ran: `$t = Get-Team
$t | Select GroupId,InternalId,DisplayName,Visibility,MailNickName,Classification,Archived,AllowGiphy,GiphyContentRating,AllowStickersAndMemes,AllowCustomMemes,AllowGuestCreateUpdateChannels,AllowGuestDeleteChannels,AllowCreateUpdateChannels,AllowCreatePrivateChannels,AllowDeleteChannels,AllowAddRemoveApps,AllowCreateUpdateRemoveTabs,AllowCreateUpdateRemoveConnectors,AllowUserEditMessages,AllowUserDeleteMessages,AllowOwnerDeleteMessages,AllowTeamMentions,AllowChannelMentions,ShowInTeamsSearchAndSuggestions |
Export-Csv -NoTypeInformation -delimiter "t" C:\ETL\teams.csv
Upon inspecting the exported file I had 1 entirely blank row. When I went back through the PowerShell output I see this in the output where I have the blank row:
Error retrieving Team with GroupId [abc-1-2-3]. ErrorCode: [NotFound]. ErrorMessage: No team found with Group Id abc-1-2-3
This appears to be a problem with the Get-Team command
@skghq If you run this command for problematic team, is $x equal $null afterwards?
$x = Get-Team -GroupID abc-1-2-3
$x -eq $null
@malauter:
PS C:\temp\scott\DebugTeam\cwd> $x = Get-Team -GroupID abc-1-2-3
PS C:\temp\scott\DebugTeam\cwd> $x -eq $null
True
@skghq Thanks! I will adjust the resource to skip such Teams during export.
@malauter This topic keeps being brought and it seems there's different opinions on how to solve it. I already had issues in the past with Intune role assignments and this morning with a customer also a problem with a Teams group assignment where the group is essentially deleted and/or orphaned, but the times I've seen reported here these kind of issues the reply was that it should be dealt with MS support instead of changing the code.
Has this opinion changed in the meantime? If yes there are other places where this problem occurs, such as the examples I gave above, and that will need the code changed to cope with this kind of problem.
@malauter One more interesting item to note... I consistently get failures for "abc-1-2-3" ... I don't know where it's pulling the GroupId from if it doesn't have a team? I'll look in to it.
What I'm randomly getting when running Get-Team is this:
Error retrieving Team with GroupId [def-9-8-7]. ErrorCode: [BadGateway]. ErrorMessage: Failed to execute backend request.
This might be a throttling issue.
@ricmestre It is just my personal opinion, but in this case the Export method cannot even call the Get method, because we have a validation of the display name length (min length = 1) in the Get function. This is why we see this error. To handle this, I would only call the Get method if there is a display name. This is just my opinion. I will create a PR and then let's see if it will be approved.
OK, let's wait and see what's their opinion on this, but see below, the export during TeamsGroupPolicyAssignment is trying to deserialize the DisplayName of $Group[0] but if it's $null, such as a deleted group like I explained one of my customers has, then the export of that resource stops completely. Fortunately in this case it just missed an additional assignment and not dozens or hundreds, in the meantime they raised a ticket with MS support to sort the deletion of that specific assignment since they are not able to do it due to an error being caused by that deleted group.
@ricmestre Is there a Github issue for this? I think we should not mix similar issues for different resources here.
I'm not mixing, I'm giving an example where the same type of issue happens on another resource. I didn't raise PRs to fix those issues myself for similar cases on other resources because like I said in the past the reply I got was that I had to solve the issue in the tenant instead of changing the code.
Description of the issue
It appears I have a Team with a blank/empty DisplayName which is causing the export to fail.
[2024/03/05 04:22:27] {InvalidData} System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'DisplayName'. The character length (0) of the argument is too short. Specify an argument with a length that is greater than or equal to "1", and then try the command again. ---> System.Management.Automation.ValidationMetadataException: The character length (0) of the argument is too short. Specify an argument with a length that is greater than or equal to "1", and then try the command again. at System.Management.Automation.ValidateLengthAttribute.ValidateElement(Object element) at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction
2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) "Error during Export:" at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.228.1\DSCResources\MSFT_TeamsTeam\MSFT_TeamsTeam.psm1: line 727 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.228.1\Modules\M365DSCReverse.psm1: line 649 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.228.1\Modules\M365DSCUtil.psm1: line 1357 atMicrosoft 365 DSC Version
1.24.228.1
Which workloads are affected
Teams
The DSC configuration
Verbose logs showing the problem
Environment Information + PowerShell Version