diff --git a/Modules/MSCloudLoginAssistant/MSCloudLoginAssistant.psd1 b/Modules/MSCloudLoginAssistant/MSCloudLoginAssistant.psd1 index 29ffaee..d6d2101 100644 --- a/Modules/MSCloudLoginAssistant/MSCloudLoginAssistant.psd1 +++ b/Modules/MSCloudLoginAssistant/MSCloudLoginAssistant.psd1 @@ -3,7 +3,7 @@ # # Generated by: Team Microsoft365DSC # -# Generated on: 2021/12/09 +# Generated on: 2021/12/10 # @{ @@ -12,7 +12,7 @@ RootModule = 'MSCloudLoginAssistant.psm1' # Version number of this module. - ModuleVersion = '1.0.81' + ModuleVersion = '1.0.82' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/Modules/MSCloudLoginAssistant/Workloads/MicrosoftGraph.psm1 b/Modules/MSCloudLoginAssistant/Workloads/MicrosoftGraph.psm1 index c4ca75e..42177aa 100644 --- a/Modules/MSCloudLoginAssistant/Workloads/MicrosoftGraph.psm1 +++ b/Modules/MSCloudLoginAssistant/Workloads/MicrosoftGraph.psm1 @@ -41,9 +41,21 @@ function Connect-MSCloudLoginMicrosoftGraph { if ($Global:MSCloudLoginConnectionProfile.MicrosoftGraph.AuthenticationType -eq 'ServicePrincipalWithThumbprint') { - Connect-MgGraph -ClientId $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ApplicationId ` - -TenantId $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.TenantId ` - -CertificateThumbprint $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.CertificateThumbprint | Out-Null + try + { + Connect-MgGraph -ClientId $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ApplicationId ` + -TenantId $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.TenantId ` + -CertificateThumbprint $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.CertificateThumbprint ` + -ErrorAction Stop | Out-Null + } + catch + { + # Check into the localmachine store + $cert = Get-ChildItem "Cert:\LocalMachine\My\$($Global:MSCloudLoginConnectionProfile.MicrosoftGraph.CertificateThumbprint)" + Connect-MgGraph -ClientId $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ApplicationId ` + -TenantId $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.TenantId ` + -Certificate $cert | Out-Null + } $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ConnectedDateTime = [System.DateTime]::Now.ToString() $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.MultiFactorAuthentication = $false $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.Connected = $true