Office 365 heath status issue after enabling MFA

Welcome Forums General PowerShell Q&A Office 365 heath status issue after enabling MFA

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 3 months ago.

  • Author
  • #82745

    Points: 0
    Rank: Member

    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.


    $cred = get-credential
    $jsonPayload = (@{userName=$cred.username;password=$cred.GetNetworkCredential().password;} | convertto-json).tostring()
    $cookie = (invoke-restmethod -contenttype "application/json" -method Post -uri "" -body $jsonPayload).RegistrationCookie

    $jsonPayload = (@{lastCookie=$cookie;locale="en-US";preferredEventTypes=@(0,1)} | convertto-json).tostring()
    $events = (invoke-restmethod -contenttype "application/json" -method Post -uri "" -body $jsonPayload)

    Thank you in advance

  • #82751

    Points: 65
    Rank: Member

    Try this:

    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.

The topic ‘Office 365 heath status issue after enabling MFA’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort