Created
June 9, 2017 09:29
-
-
Save zplume/5e27958a65ff0b63466297da278c1b81 to your computer and use it in GitHub Desktop.
Converts the bizarre JSON-in-CSV format of O365 audit logs to a more useful CSV of the JSON data. Run the script from the directory containing the $inputFile or specify a full path rather than just a file name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$inputFile = "AuditLog_2017-05-18_2017-05-27.csv" | |
$outputFile = "AuditLogData.csv" | |
Import-Csv -Path $inputFile | ForEach-Object { $_.AuditData } | ConvertFrom-Json | Export-Csv -Path $outputFile -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for this script zplume!
There is a bug beacuse there is json inside json and it print only the "first object":
"ExtendedProperties"":[{""Name"":""ResultStatusDetail"",""Value"":""Success""},{""Name"":""UserAgent"",""Value"":""Android/10-EAS-2.0""},{""Name"":""UserAuthenticationMethod"",""Value"":""16""},{""Name"":""RequestType"",""Value"":""OAuth2:Token""}]
Script Result is:
ExtendedProperties=System.Object[]
Found this function that can help: https://stackoverflow.com/questions/45829754/convert-nested-json-array-into-separate-columns-in-csv-file