Forum Discussion

Learner2023's avatar
Learner2023
Copper Contributor
Aug 18, 2024

Unable to run Export-MsIdAzureMfaReport getting error please advise

Unable to run Export-MsIdAzureMfaReport .\report.xlsx getting errors

PowerShell 7.4.4

PS C:\Windows\System32> Connect-MgGraph -Scopes Directory.Read.All, AuditLog.Read.All, UserAuthenticationMethod.Read.All

Welcome to Microsoft Graph!

Connected via delegated access using ******************************

NOTE: You can use the -NoWelcome parameter to suppress this message.

PS C:\Windows\System32> Export-MsIdAzureMfaReport .\Temp\report.xlsx

Compare-Object: Cannot bind argument to parameter 'DifferenceObject' because it is null.

Compare-Object: Cannot bind argument to parameter 'DifferenceObject' because it is null.

Write-Error: Unable to find target address

PS C:\Windows\System32>

Please help! Thanks.

 

3 Replies

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    Learner2023 

     

    Hi, Haroon.

     

    From reading the source code on git, it appears the failure is occurring within the Test-MgModulePrerequisites function, where the results from Get-MgContext are used.

     

    What output do you get - if any - if you run the following cmdlet in lieu of the Export-MsIdAzureMfaReport cmdlet?

     

    (Get-MgContext).Scopes;

     

    Cheers,

    Lain

  • Run it in VSCode, check what line uses Compare-Object, and see how the variable referenced by DifferenceObject is filled. But first, run the script with the -Verbose parameter to see what's happening.

Resources