Office 365 heath status issue after enabling MFA

This topic contains 1 reply, has 2 voices, and was last updated by  Jon 3 weeks, 4 days ago.

  • Author
    Posts
  • #82745

    Deep
    Participant

    Hi All,

    I was using below script to fetch office 365 health status report it was working as expected till the day.
    We enabled MFA and now the script is not working.

    can someone help in this, how shall I authenticate the API in MFA enabled environment.

    URL: https://blogs.technet.microsoft.com/cammurray/2014/09/23/using-powershell-to-obtain-your-tenants-office365-health-dashboard/

    $cred = get-credential
    $jsonPayload = (@{userName=$cred.username;password=$cred.GetNetworkCredential().password;} | convertto-json).tostring()
    $cookie = (invoke-restmethod -contenttype "application/json" -method Post -uri "https://api.admin.microsoftonline.com/shdtenantcommunications.svc/Register" -body $jsonPayload).RegistrationCookie

    $jsonPayload = (@{lastCookie=$cookie;locale="en-US";preferredEventTypes=@(0,1)} | convertto-json).tostring()
    $events = (invoke-restmethod -contenttype "application/json" -method Post -uri "https://api.admin.microsoftonline.com/shdtenantcommunications.svc/GetEvents" -body $jsonPayload)

    Thank you in advance

  • #82751

    Jon
    Participant

    Try this:

    https://technet.microsoft.com/en-us/library/mt775114(v=exchg.160).aspx

    Additionally you could look at creating a claims rule on your ADFS server to not require MFA for powershell, or a specific internal network range.

You must be logged in to reply to this topic.