powershell - 使用 powershell 从 azure DevOps UI 下载 csv 中的审计日志
问题描述
嗨,我正在寻找一个脚本,它可以在给定的时间范围内使用 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
结果:
推荐阅读
- javascript - 滚动动画
- sql-server - 将值从 Excel 更新到 Sql Server
- java - 从 maven 迁移到 gradle 时找不到主类错误
- python - 尝试使用 python 将 csv 文件的值输入到 mysql 数据库中
- mongodb - 在 tomcat 容器中运行 Hazelcast 客户端
- c# - 有什么办法可以查出APK文件是从哪里下载的?
- python - 从 UDP 中刮掉 8 个字节的 scapy 有效负载
- sql - BigQuery 按日期过滤
- itext - 用 itext7 填写 PDF/A3-Acroform 会使 PDF 失去其 PDF/A3 合规性,我不知道为什么
- android - com.google.android.gms:play-services-measurement-base 正在被其他各种库请求