Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $target = "C:tempmessages.csv"
- #Connect-MsolService
- $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=@(2)} | convertto-json).tostring()
- $events = (invoke-restmethod -contenttype "application/json" -method Post -uri "https://api.admin.microsoftonline.com/shdtenantcommunications.svc/GetEvents" -body $jsonPayload)
- $events.Events | export-csv -LiteralPath $target -NoTypeInformation
Add Comment
Please, Sign In to add comment