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

Export of TeamsTeam resource fails when using certificate thumbprint #3183

Closed
leitzler opened this issue Apr 19, 2023 · 0 comments · Fixed by #3203 or #3229
Closed

Export of TeamsTeam resource fails when using certificate thumbprint #3183

leitzler opened this issue Apr 19, 2023 · 0 comments · Fixed by #3203 or #3229

Comments

@leitzler
Copy link

Details of the scenario you tried and the problem that is occurring

I exported a clean developer tenant with default sample data using certificate thumbprint and Full mode:

Export-M365DSCConfiguration -CertificateThumbprint $Cert.Thumbprint -TenantId <redacted>.onmicrosoft.com -ApplicationId 01234567-890a-bcde-f012-34567890abcd -Path full -Mode Full -MaxProcesses 64

It gives me an error message during export:

[234/249] Extracting [TeamsTeam] using {CertificateThumbprint}...❌

I did find an error log in the root, probably related:

[2023/04/19 01:04:23]
{InvalidOperation}
System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
   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.412.1\DSCResources\MSFT_TeamsTeam\MSFT_TeamsTeam.psm1: line 683
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.412.1\modules\M365DSCReverse.psm1: line 615
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.412.1\modules\M365DSCUtil.psm1: line 1295
at <ScriptBlock>, <No file>: line 1
TenantId: foobar.onmicrosoft.com

Looking at the code it seems like the use of certificate thumbnail isn't detected properly, I assume we should have ended up in the ServicePrincipal branch and not at line 683 as the stack trace shows:

if ($ConnectionMode -eq 'ServicePrincipal')
{
$organization = Get-M365DSCTenantDomain -ApplicationId $ApplicationId -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint
}
else
{
$organization = $Credential.UserName.Split('@')[1]
}

API Permissions, all granted:

Microsoft Graph (25)
* AdministrativeUnit.Read.All - Application
* Agreement.Read.All - Application
* Application.Read.All - Application
* ChannelSettings.Read.All - Application
* DeviceManagementApps.Read.All - Application
* DeviceManagementApps.ReadWrite.All - Application
* DeviceManagementConfiguration.Read.All - Application
* DeviceManagementConfiguration.ReadWrite.All - Application
* DeviceManagementManagedDevices.Read.All - Application
* DeviceManagementRBAC.Read.All - Application
* DeviceManagementRBAC.ReadWrite.All - Application
* DeviceManagementServiceConfig.Read.All - Application
* Directory.Read.All - Application
* Domain.Read.All - Application
* EntitlementManagement.Read.All - Application
* EntitlementManagement.ReadWrite.All - Application
* Group.Read.All - Application
* Organization.Read.All - Application
* Policy.Read.All - Application
* RoleManagement.Read.Directory - Application
* RoleManagementPolicy.Read.Directory - Application
* Sites.FullControl.All - Application
* Tasks.Read.All - Application
* User.Read - Delegated
* User.Read.All - Application
Office 365 Exchange Online (1)
* Exchange.ManageAsApp - Application
SharePoint (2)
* Sites.FullControl.All - Application
* User.Read.All - Application

Roles assigned: Teams Administrator, Global Reader & Global Administrator.

Verbose logs showing the problem

See above.

Suggested solution to the issue

N/A

The DSC configuration that is used to reproduce the issue (as detailed as possible)

Using Windows Server Core container, mcr.microsoft.com/windows/servercore:1809-amd64.

Install-PackageProvider -Name NuGet -Force
Install-Module Microsoft365DSC -Force
Update-M365DSCDependencies

The operating system the target node is running

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}

Version of the DSC module that was used ('dev' if using current dev branch)

1.23.412.1 Microsoft365DSC                     PSGallery            This DSC module is used to configure and monitor Microsoft tenants, including SharePoint Online, Exchange, Teams, etc.
NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Apr 21, 2023
serial666 added a commit to serial666/Microsoft365DSC that referenced this issue Apr 24, 2023
NikCharlebois added a commit that referenced this issue Apr 24, 2023
TeamsTeam: Finish the fix for issue #3183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant