使用Powershell从Azure DevOps UI下载CSV中的审核日志 [英] Download audit logs in csv from azure DevOps UI using powershell

查看:34
本文介绍了使用Powershell从Azure DevOps UI下载CSV中的审核日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个脚本,该脚本可以在给定的时间范围内使用powershell从azure DevOps中下载csv中的导出日志.像我可以输入时间范围,然后脚本将从azure DevOps ui下载并返回csv文件-

我在这里

Hi I am looking for a script which can download export logs in csv from azure DevOps using powershell for given time frame. like I can enter time frame and then script will download and return csv file from azure DevOps ui -

I found this script here https://developercommunity.visualstudio.com/content/problem/615053/question-we-want-to-get-the-export-audit-log-using.html

I am not sure what username , password and url to use here

$Username = 'domain\user'
$Password = 'password'
$Url = "https://server:8080/tfs/_api/_licenses/Export"
$Path = "D:\temp\data.csv"
$WebClient = New-Object System.Net.WebClient
$WebClient.Credentials = New-Object    
System.Net.Networkcredential($Username, $Password)
$WebClient.DownloadFile( $url, $path )

I am not able to find any more data on this

解决方案

The sample you shared is download audit log form Azure DevOps Server, the url is https://{your_server}/tfs/_api/_licenses/Export, username , password are your username and password to log on to TFS. Note: Do not forget add domain name before the username.

If you are using Azure DevOps Service, you can try this REST API and power shell script to save the Audit log.

$outfile = "{Local path}"
$connectionToken="{PAT}"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$AuditLogURL = "https://auditservice.dev.azure.com/{organization}/_apis/audit/downloadlog?format=csv&startTime={startTime}&endTime={endTime}&api-version=6.1-preview.1" 
$AuditInfo = Invoke-RestMethod -Uri $AuditLogURL -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get –OutFile $outfile

Result:

这篇关于使用Powershell从Azure DevOps UI下载CSV中的审核日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆