Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Unable to Export Intune Configuration with AppID and Secret

Open RuudGijsbers opened this issue 5 years ago • 0 comments

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

When I try to export the Intune configuration with appid and secret:

Export-M365DSCConfiguration -Quiet -ComponentsToExtract @("IntuneDeviceConfigurationPolicyiOS") -ApplicationId $ApplicationId -ApplicationSecret $ApplicationSecret -TenantId $TenantId

I get the following error message:

Connecting to {Intune}...❌ Cannot bind argument to parameter 'CertificateThumbprint' because it is an empty string.

Verbose logs showing the problem

The last part of the verbose logging:

VERBOSE: Importing function 'Export-TargetResource'. VERBOSE: Importing function 'Get-TargetResource'. VERBOSE: Importing function 'Set-TargetResource'. VERBOSE: Importing function 'Test-TargetResource'. VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.21.908.1\DSCResources\MSFT_TeamsVoiceRoutingPolicy\MSFT_TeamsVoiceRou tingPolicy.psm1'. VERBOSE: Importing function 'Export-TargetResource'. VERBOSE: Importing function 'Get-TargetResource'. VERBOSE: Importing function 'Set-TargetResource'. VERBOSE: Importing function 'Test-TargetResource'. Connecting to {Intune}...❌ Cannot bind argument to parameter 'CertificateThumbprint' because it is an empty string. Partial Export file was saved at: C:\Users\user\AppData\Local\Temp\5575be6f-f160-4fb1-8212-e6d8d0c1d6c0.partial.ps1.ps1.partial

Suggested solution to the issue

After a first investigation, it looks like it has something to do with the new MSCloudLoginAssistant module.

In the ConnectionProfile.psm1 it checks for $Global:AttemptedToGetOrganizationName if that's empty it will try to get the OrganizationName: if ($null -eq $Global:AttemptedToGetOrganizationName) { $Global:AttemptedToGetOrganizationName = $true $domain = Get-MSCloudLoginOrganizationName -ApplicationId $this.ApplicationId -TenantId $this.TenantId -CertificateThumbprint $this.CertificateThumbprint }` Get-MSCloudLoginOrganizationName only accepts a CertificateThumbprint instead of an app secret I'm also wondering if the authentication the App ID isn't missing in Intune.psm1

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

Export-M365DSCConfiguration -Quiet -ComponentsToExtract @("IntuneDeviceConfigurationPolicyiOS") -ApplicationId $ApplicationId -ApplicationSecret $ApplicationSecret -TenantId $TenantId

The operating system the target node is running

OsName : Microsoft Windows 11 Enterprise OsOperatingSystemSKU : EnterpriseEdition OsArchitecture : 64-bit WindowsVersion : 2009 WindowsBuildLabEx : 22000.1.amd64fre.co_release.210604-1628 OsLanguage : en-US OsMuiLanguages : {en-US}

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

Version 1.21.908.1 was used

RuudGijsbers avatar Sep 08 '21 19:09 RuudGijsbers