Closed skghq closed 8 months ago
I have upgraded to 1.23.1122.1. This is still an issue.
I also re-ran it with the "-Verbose" parameter but no additional useful information was recorded.
VERBOSE: Dependencies were already successfully validated.
VERBOSE: Credential was specified. Connecting via User Principal
VERBOSE: Dependencies were already successfully validated.
✅
PS>TerminatingError(Get-TeamChannel): "Cannot bind argument to parameter 'GroupId' because it is null."
❌
Error Log created at {file://C:/temp/<<
@skghq Could you please check the output of Get-Team for any groups without a GroupId? Normally each group must have a valid Id, but your log says it is null for one of the groups and I cannot reproduce this in my environment.
@malauter Minimally redacted:
PS C:\temp\scott\debug\cwd> Get-Team -DisplayName "Project Rebrand"
GroupId DisplayName Visibility Archived MailNickName Description
------- ----------- ---------- -------- ------------ -----------
01b0b86b-3610-488c-adae-54763d6e33d9 Project Rebrand Private False ProjectRebrand Project Rebrand
PS C:\temp\scott\debug\cwd> Get-Team -DisplayName "AR Team"
GroupId DisplayName Visibility Archived MailNickName Description
------- ----------- ---------- -------- ------------ -----------
791ba05f-4bd2-4953-8f30-3a80b07fe2b3 AR Team Private False ARTeam33 We will place s...
b9f8cbde-0e83-4bcc-9b88-8c6cdde22009 <NAME 1> v. NNN... Private False <NAME 1>.TeamP... <NAME 1> v. NNN...
6811f029-0c77-4ea5-982b-b09138681a21 AR Team Private False ARTeam AR Team
cc22a431-b91d-4ea1-9ac9-8afb26efe9ac <NAME 2> v YYY -... Private False <NAME 2>-XXX... <NAME 2> v YYY -...
PS C:\temp\scott\debug\cwd> Get-Team -DisplayName "AR Team" -Debug -Verbose
VERBOSE: Done performing authorization
VERBOSE: Executing Get-Team for parameters GroupId: , User: , Archived: , Visibility: , DisplayName: AR Team, MailNickName:
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="displayName:AR Team"
VERBOSE: Attempting to retrieve team from indexes [0 to 3]
DEBUG: Processed Batch number : 1
DEBUG: Returning 4 teams
DEBUG: Failed to fetch 0 teams
VERBOSE: Retrieving groups list
GroupId DisplayName Visibility Archived MailNickName Description
------- ----------- ---------- -------- ------------ -----------
791ba05f-4bd2-4953-8f30-3a80b07fe2b3 AR Team Private False ARTeam33 We will place s...
b9f8cbde-0e83-4bcc-9b88-8c6cdde22009 <NAME 1> v. NNN... Private False <NAME 1>.TeamP... <NAME 1> v. NNN...
6811f029-0c77-4ea5-982b-b09138681a21 AR Team Private False ARTeam AR Team
cc22a431-b91d-4ea1-9ac9-8afb26efe9ac <NAME 2> v YYY -... Private False <NAME 2>-XXX... <NAME 2> v YYY -...
VERBOSE: Done retrieving groups, getting team properties
VERBOSE: Done processing Get-Team
@skghq The display name 'AR Team' is not unique, but this should not be a problem, this is why we are using the group id. I do not know why the group id could not be found during the export for one of your teams.
Can you still reproduce the issue with the most current version of M365 DSC and dependencies?
@malauter It looks like I gave you bad information. Yes -- I just updated to the latest version and reproduced it. 'AR Team' actually exports fine. It is the next team that fails.
If I look at the produced error log (Error Log created at {file://C:/temp/scott/debug/cwd/876-M365DSC-ErrorLog.log}) the last team is 'AR Team'.
Looking at the console window the last team activity is for 'Evaluation Committee'
Upgrade:
Update-Module Microsoft365DSC
Update-M365DSCDependencies
Uninstall-M365DSCOutdatedDependencies
Get-InstalledModule Microsoft365DSC | Select Version,InstalledLocation
Version InstalledLocation
------- -----------------
1.23.1220.1 C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1220.1
Console Output:
|---[699/1696] Team {AR Team}
|---[1/1] GeneralVERBOSE: Attempting connection to {MicrosoftTeams} with:
VERBOSE:
Name Value
---- -----
TenantId
DisplayName General
GroupID 6811f029-0c77-4ea5-982b-b09138681a21
TeamName AR Team
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.
✅
|---[700/1696] Team {Evaluation Committee}
|---[1/4] 2022 Evaluation CommitteeVERBOSE: Attempting connection to {MicrosoftTeams} with:
VERBOSE:
Name Value
---- -----
TenantId
DisplayName 2022 Evaluation Committee
GroupID 6967ff87-993c-42b1-ab87-679e038cd171
TeamName Evaluation Committee
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.
✅
|---[2/4] AdminVERBOSE: Attempting connection to {MicrosoftTeams} with:
VERBOSE:
Name Value
---- -----
TenantId
DisplayName Admin
GroupID 6967ff87-993c-42b1-ab87-679e038cd171
TeamName Evaluation Committee
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.
✅
|---[3/4] 2023VERBOSE: Attempting connection to {MicrosoftTeams} with:
VERBOSE:
Name Value
---- -----
TenantId
DisplayName 2023
GroupID 6967ff87-993c-42b1-ab87-679e038cd171
TeamName Evaluation Committee
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.
✅
|---[4/4] GeneralVERBOSE: Attempting connection to {MicrosoftTeams} with:
VERBOSE:
Name Value
---- -----
TenantId
DisplayName General
GroupID 6967ff87-993c-42b1-ab87-679e038cd171
TeamName Evaluation Committee
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.
✅
❌
Error Log created at {file://C:/temp/scott/debug/cwd/876-M365DSC-ErrorLog.log}
⌛ Export took {2173 seconds}
Transcript stopped, output file is C:\temp\scott\debug\log\TeamsChannel2.txt
Get-Team:
PS C:\temp\scott\debug\cwd> Get-Team -DisplayName "Evaluation Committee"
GroupId DisplayName Visibility Archived MailNickName Description
------- ----------- ---------- -------- ------------ -----------
6967ff87-993c-42b1-ab87-679e038cd171 Evaluation Comm... Private False EvaluationCommi... Manage tasks, s...
Get-TeamChannel for 'Evaluation Committee' (NOT WORKING):
PS C:\temp\scott\debug\cwd> Get-TeamChannel -GroupId 6967ff87-993c-42b1-ab87-679e038cd171
Id DisplayName Description MembershipType
-- ----------- ----------- --------------
19:1c0b879e0a3c4463b86cc3ce563641b4@thread.tacv2 2022 Evaluation Committee Standard
19:81a39ce41bd84bdf823f87614b77ab5b@thread.tacv2 Admin Private
19:e42a1c545f894029a17bda1eb59e981a@thread.tacv2 2023 Standard
19:I48qlnbQ8VbX8LSZuiooZiceUdJ92ujRtDTYS6i7IYE1@thread.tacv2 General Manage tasks, share documents, conduct project meetings and document risks and decisions with this template for general project management. Standard
Get-TeamChannel for 'AR Team' (WORKING):
PS C:\temp\scott\debug\cwd> Get-TeamChannel -GroupId 6811f029-0c77-4ea5-982b-b09138681a21
Id DisplayName Description MembershipType
-- ----------- ----------- --------------
19:c71b086258584f28987e4fb3df819c3e@thread.tacv2 General AR Team Standard
@malauter The "Membership Type" of private seems to stand out to me in the Get-TeamChannel output.
@skghq Thanks for all the information. I have just created the same Team structure, even with a private channel, but still I cannot reproduce the issue. Is this the only team/channel in your tenant causing the issue? The error says, that the group id of the team (not of the channel) is null, but if you run the cmdlet manually, the id is not null.
@malauter The script stops execution after the error so i'm not sure if that is the only team. I'll give debugging the script a go and let you know what I find. Any input on approaching this would be helpful.
@malauter I found the problem. Bad information again. Using the stack trace of the error i modified your code.
Stack trace:
[2023/12/27 09:59:45]
{InvalidData}
System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'GroupId' because it is null.
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.23.1220.1\DSCResources\MSFT_TeamsChannel\MSFT_TeamsChannel.psm1: line 388
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1220.1\modules\M365DSCReverse.psm1: line 639
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1220.1\modules\M365DSCUtil.psm1: line 1312
at <ScriptBlock>, C:\Scripts\Scott\From-VW19ADMINSRV\GitHub-3943.ps1: line 27
I insert a line at 383 of MSFT_TeamsChannel.psm1:
try
{
$teams = Get-Team -ErrorAction Stop
$teams | Export-Csv -NoTypeInformation -delimiter "`t" C:\ETL\Production\365dsc_debug.txt # DEBUG CODE
$j = 1
$dscContent = ''
Write-Host "`r`n" -NoNewline
I then imported the results of that to SQL:
/*
SELECT *
INTO DataPond_Staging.._DEBUG_365
FROM OPENROWSET(
'Microsoft.ACE.OLEDB.16.0',
'Text; HDR=YES; Database=C:\ETL\Production\',
'SELECT * FROM 365dsc_debug.txt')
*/
select *
from DataPond_Staging.._DEBUG_365
'AR Team' and 'Evaluation Committee' are not at fault. See attached screenshot. I'm not sure how to go about providing you more information on this:
I have no idea why there is this "NULL team" in your tenant. I think the only thing we can do is to adjust the code to skip the team if the GroupId is null. @NikCharlebois What do you think?
@skghq Could you please test if the adjusted code from the PR linked above solves your issue?
Description of the issue
I will update to the latest version when I have a chance in a few days.
Command:
Export-M365DSCConfiguration -Components @("TeamsChannel") -Credential $Credential -Path $FilePath -FileName $FileName
Stack Trace: [2023/11/23 09:30:53] {InvalidData} System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'GroupId' because it is null. 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.23.1115.1\DSCResources\MSFT_TeamsChannel\MSFT_TeamsChannel.psm1: line 388 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1: line 615 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCUtil.psm1: line 1320 at, C:\Scripts\<<>>\Office365_Backup_Debug.ps1: line 5629
<<redacted>>>@<<<redacted>>.onmicrosoft.com
TenantId: <<>>.onmicrosoft.com
PS Output: Transcript started, output file is C:\temp\<<>>\debug\log\TeamsChannel.txt
Exporting Microsoft 365 configuration for Components: TeamsChannel
There is a newer version of the 'Microsoft365DSC' module available on the gallery.
To update the module and it's dependencies, run the following command:
Update-M365DSCModule
Authentication methods specified:
Connecting to {MicrosoftTeams}...✅ [1/1] Extracting [TeamsChannel] using {Credentials}...
<<< a lot of output>>>
❌ Error Log created at {file://C:/temp/<<>>/debug/cwd/5112-M365DSC-ErrorLog.log}
⌛ Export took {2232 seconds}
Transcript stopped, output file is C:\temp\<<>>\debug\log\TeamsChannel.txt
Microsoft 365 DSC Version
1.23.1115.1
Which workloads are affected
Teams
The DSC configuration
Verbose logs showing the problem
Environment Information + PowerShell Version