Skip to content

Instantly share code, notes, and snippets.

@goyalmohit
Created July 21, 2019 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goyalmohit/906d44f3f56e0acea52b57261ecb97b7 to your computer and use it in GitHub Desktop.
Save goyalmohit/906d44f3f56e0acea52b57261ecb97b7 to your computer and use it in GitHub Desktop.
# This code parse the audit logs exported from azure devops and saved as file auditlog.json
function Parse-AzureDevOpsAuditLogs {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $Path
)
Begin {
Write-Verbose "In Begin Block: Parse-AzureDevOpsAuditLogs"
}
Process{
Write-Verbose "In Process Block: Parse-AzureDevOpsAuditLogs"
if (!(Test-Path $Path)){
Write-Host "The mentioned file: $Path not found."
return
}
$auditLogs = Get-Content -Path $Path | ConvertFrom-Json
Write-Host "Timestamp `t ScopeType `t ProjectName `t IpAddress `t Details `t Area `t CategoryDisplayName"
foreach($auditlog in $auditLogs){
Write-Host "$($auditLog.Timestamp) `t $($auditLog.ScopeType) `t $($auditLog.ProjectName) `t $($auditLog.IpAddress) `t $($auditLog.Details) `t $($auditLog.Area) `t $($auditLog.CategoryDisplayName)"
}
}
End {
Write-Verbose "In End Block: Parse-AzureDevOpsAuditLogs"
}
}
Parse-AzureDevOpsAuditLogs -Path .\auditLog.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment