microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.59k stars 500 forks source link

Export-M365DSCConfiguration: cannot connect to Microsoft Graph #2505

Closed bstets1 closed 1 year ago

bstets1 commented 1 year ago

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

After updating to version 1.22.1102.1 using Application authentication, try to run the Export-M365DSCConfiguration command I get: Connecting to {MicrosoftGraph}...❌ A parameter cannot be found that matches parameter name 'Identity'.

command I am running: Export-M365DSCConfiguration -TenantId $tenantName -ApplicationId $clientId -ApplicationSecret $clientSecret

Verbose logs showing the problem

Suggested solution to the issue

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

# insert configuration here

The operating system the target node is running

OsName : Microsoft Windows 11 Enterprise OsOperatingSystemSKU : EnterpriseEdition OsArchitecture : 64-bit WindowsVersion : 2009 WindowsBuildLabEx : 22621.1.amd64fre.ni_release.220506-1250 OsLanguage : en-US OsMuiLanguages : {en-US}

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

bstets1 commented 1 year ago

I found the Microsoft.Graph.Authentication was at version 1.9.6, I was able to update to 1.15.0 and am now getting the below error: Exporting Microsoft 365 configuration for Components: AADApplication

Authentication methods specified:

Get-MgOrganization_List1: Method not found: 'System.Net.Http.HttpClient Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient(System.Management.Automation.InvocationInfo, Microsoft.Graph.PowerShell.Authentication.IAuthContext)'.

You cannot call a method on a null-valued expression. Partial Export file was saved at: PS > Get-Module
ModuleType Version PreRelease Name ExportedCommands


Script 1.15.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…} Script 1.9.6 Microsoft.Graph.Identity.Directory… {Confirm-MgContactMemberGroup, Confirm-MgContactMemberObject, Confirm-MgContractMemberGroup, Confirm-MgCon… Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…} Manifest 7.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature…} Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…} Manifest 1.22.1102… Microsoft365DSC {Add-M365DSCEvent, Add-M365DSCTelemetryEvent, Assert-M365DSCBlueprint, Compare-M365DSCConfigurations…}
Script 1.0.84 MSCloudLoginAssistant {Connect-M365Tenant, Connect-MSCloudLoginAzure, Connect-MSCloudLoginAzureAD, Connect-MSCloudLoginAzureADMF… Script 1.4.7 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider…} Script 0.2.0 PowerShellEditorServices.Commands {Clear-Host, ConvertFrom-ScriptExtent, ConvertTo-ScriptExtent, Find-Ast…} Binary 0.2.0 PowerShellEditorServices.VSCode {Close-VSCodeHtmlContentView, New-VSCodeHtmlContentView, Set-VSCodeHtmlContentView, Show-VSCodeHtmlContent… Script 2.2.6 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}

andikrueger commented 1 year ago

Could you run Update-M365DSCDependencies and Uninstall-M365DSCOutdatedDependencies

bstets1 commented 1 year ago

Thank you Andi for your response, I ran both of those commands, the update scanned but did not update any dependencies, I did run that after I had first updated to 1.22.1102.1. The Uninstall did remove a bunch of Modules, which re-running the Export-M365DSCConfiguration did login and work this time, but it also now gave me this: New version of {Microsoft.Graph.Applications} is available {1.15.0} New version of {Microsoft.Graph.Authentication} is available {1.15.0} New version of {Microsoft.Graph.DeviceManagement} is available {1.15.0} New version of {Microsoft.Graph.DeviceManagement.Administration} is available {1.15.0} New version of {Microsoft.Graph.DeviceManagement.Enrolment} is available {1.15.0} New version of {Microsoft.Graph.Devices.CorporateManagement} is available {1.15.0} New version of {Microsoft.Graph.Groups} is available {1.15.0} New version of {Microsoft.Graph.Identity.DirectoryManagement} is available {1.15.0} New version of {Microsoft.Graph.Identity.Governance} is available {1.15.0} New version of {Microsoft.Graph.Identity.SignIns} is available {1.15.0} New version of {Microsoft.Graph.Planner} is available {1.15.0} New version of {Microsoft.Graph.Teams} is available {1.15.0} New version of {Microsoft.Graph.Users} is available {1.15.0} New version of {Microsoft.Graph.Users.Actions} is available {1.15.0} New version of {MSCloudLoginAssistant} is available {1.0.97}

Running the Update-M365DSCDependencies command again did not update any thing further

andikrueger commented 1 year ago

Thank you for the additional information and confirmation, that it’s working now. I’ll look into the confusion messages about newer modules being available. Those are not part of your installed version of microsoft365dsc.