Unable to export Conditional Access policies due to dependant module version mismatch
When I try to extract the AAD Conditional Access policies using this cmd:
Export-M365DSCConfiguration -Components @("AADConditionalAccessPolicy") -ApplicationId $ApplicationId -CertificateThumbprint $CertificateThumbprint -TenantId $TenantId -FileName "AADConditionalAccessPolicy.ps1" -Path "C:\M365DSC\src"
I get this error:
Get-MgIdentityConditionalAccessPolicy : Could not load file or assembly 'Microsoft.Graph.Authentication, Version=0.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.22.216.1\DSCResources\MSFT_AADConditionalAccessPolicy\MSFT_AADConditionalAccessPolicy.psm1:1965 char:9
+ [array] $Policies = Get-MgIdentityConditionalAccessPolicy
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-MgIdentityC...essPolicy_List1], FileNotFoundException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgIdentityConditionalAccessPolicy_List1
In "C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Authentication" is a single folder "1.9.2".
If I delete the "1.9.2" folder and install "0.9.1", Export-M365DSCConfiguration automatically installs "1.9.2" again, as does Update-M365DSCDependencies, and fails with same error.
M365DSC v1.22.216.1 Windows 10
It should use Microsoft.Graph.Authentication in Version "1.9.2". Please make sure to delete all previous versions of the modules within this file:
https://github.com/microsoft/Microsoft365DSC/blob/Dev/Modules/Microsoft365DSC/Dependencies/Manifest.psd1
I did have a similar error and got around this issue by deleting all old versions of the dependent modules. Additionally you could do a get-command Get-MgIdentityConditionalAccessPolicy to see, if there are any further modules available, that would export this command.
Check if you have the module Microsoft.Graph.Identity.ConditionalAccess and delete it. The Get-MgIdentityConditionalAccessPolicy is available in Microsoft.Graph.Identity.SignIns
It worked for me.
There were no previous versions of the module in the Manifest.psd1 file.
Deleting the module folder for Microsoft.Graph.Identity.ConditionalAccess resolved the issue.
Thank you!
I am able to use Get-MgIdentityConditionalAccess now but now i am getting the following error message. Any suggestions ? Could not load file or assembly 'Microsoft.Graph.Authentication, Version=0.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. If i delete newer versions of 'Microsoft.Graph.Authentication, i cannot use the connect-mggraph function
It should use
Microsoft.Graph.Authenticationin Version "1.9.2". Please make sure to delete all previous versions of the modules within this file: https://github.com/microsoft/Microsoft365DSC/blob/Dev/Modules/Microsoft365DSC/Dependencies/Manifest.psd1I did have a similar error and got around this issue by deleting all old versions of the dependent modules. Additionally you could do a
get-command Get-MgIdentityConditionalAccessPolicyto see, if there are any further modules available, that would export this command.
if i delete newer versions i get this error connecting Connect-MgGraph : The term 'Connect-MgGraph' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:4 char:1