![](/img/trans.png)
[英]Trying to download a file from an Azure DevOps Git repo using Powershell
[英]Download audit logs in csv from azure DevOps UI using powershell
嗨,我正在寻找一个脚本,它可以在给定的时间范围内使用 powershell 从 azure DevOps 下载 csv 中的导出日志。 就像我可以输入时间范围,然后脚本将从 azure DevOps ui 下载并返回 csv 文件 -
我不确定在这里使用什么用户名、密码和 url
$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 )
我无法找到有关此的更多数据
您分享的示例是从 Azure DevOps Server 下载审核日志,url 为https://{your_server}/tfs/_api/_licenses/Export
, username , password 是您登录 TFS 的用户名和密码。 注意:不要忘记在用户名前添加域名。
如果您使用的是 Azure DevOps 服务,则可以尝试使用此REST API和 Power Shell 脚本来保存审核日志。
$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
结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.