Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TeamsTeam: 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. #4406

Closed
skghq opened this issue Mar 5, 2024 · 13 comments · Fixed by #4408
Assignees
Labels
Bug Something isn't working Teams

Comments

@skghq
Copy link

skghq commented Mar 5, 2024

Description of the issue

It appears I have a Team with a blank/empty DisplayName which is causing the export to fail.

TeamsTeam

[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.ActionCallInstruction2.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
at , : line 6`

Microsoft 365 DSC Version

1.24.228.1

Which workloads are affected

Teams

The DSC configuration

Export-M365DSCConfiguration -Components @("TeamsTeam") -Credential $Credential -Path $FilePath -FileName $FileName -Verbose -Debug

Verbose logs showing the problem

VERBOSE: Dependencies were already successfully validated.
VERBOSE: Credential was specified. Connecting via User Principal
VERBOSE: Dependencies were already successfully validated.
✅
    |---[720/1764] @@@DATA@@@VERBOSE: Attempting connection to {MicrosoftTeams} with:
VERBOSE: 
Name                           Value                                                                                                                                                                                                                                           
----                           -----                                                                                                                                                                                                                                           
TenantId                                                                                                                                                                                                                                                                       
ManagedIdentity                False                                                                                                                                                                                                                                           
DisplayName                    @@@DATA@@@
GroupID                        @@@GUID@@@
Credential                     System.Management.Automation.PSCredential                                                                                                                                                                                                       
ApplicationId                                                                                                                                                                                                                                                                  
CertificateThumbprint                                                                                                                                                                                                                                                          



VERBOSE: Dependencies were already successfully validated.
VERBOSE: Credential was specified. Connecting via User Principal
VERBOSE: Dependencies were already successfully validated.
✅
    |---[721/1764] ❌
 Error Log created at {file://C:/temp/scott/debug/cwd/9724-M365DSC-ErrorLog.log}
⌛ Export took {1024 seconds}
Transcript stopped, output file is C:\temp\scott\debug\log\TeamsTeam.txt

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2019 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Key   : PSVersion
Value : 5.1.17763.5458
Name  : PSVersion

Key   : PSEdition
Value : Desktop
Name  : PSEdition

Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions

Key   : BuildVersion
Value : 10.0.17763.5458
Name  : BuildVersion

Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion

Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion

Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion
@skghq skghq changed the title TeamsTeam: 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. TeamsTeam: 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. Mar 5, 2024
@malauter
Copy link
Member

malauter commented Mar 5, 2024

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 malauter added the Teams label Mar 5, 2024
@skghq
Copy link
Author

skghq commented Mar 5, 2024

@malauter I haven't a clue... but somehow it is in my tenant configuration...

@skghq
Copy link
Author

skghq commented Mar 5, 2024

@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

@malauter
Copy link
Member

malauter commented Mar 5, 2024

@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

@skghq
Copy link
Author

skghq commented Mar 5, 2024

@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
Copy link
Author

skghq commented Mar 5, 2024

teamsteam2

@malauter
Copy link
Member

malauter commented Mar 5, 2024

@skghq Thanks! I will adjust the resource to skip such Teams during export.

@malauter malauter self-assigned this Mar 5, 2024
@malauter malauter added the Bug Something isn't working label Mar 5, 2024
@ricmestre
Copy link
Contributor

ricmestre commented Mar 5, 2024

@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.

@skghq
Copy link
Author

skghq commented Mar 5, 2024

@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.

@malauter
Copy link
Member

malauter commented Mar 5, 2024

@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.

@ricmestre
Copy link
Contributor

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.

@malauter
Copy link
Member

malauter commented Mar 5, 2024

@ricmestre Is there a Github issue for this? I think we should not mix similar issues for different resources here.

@ricmestre
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Teams
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants