這篇文章給大家分享的是有關怎么查詢Azure用戶操作記錄的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供三江侗網(wǎng)站建設、三江侗做網(wǎng)站、三江侗網(wǎng)站設計、三江侗網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、三江侗企業(yè)網(wǎng)站模板建站服務,十余年三江侗做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。
下邊來看下代碼的內(nèi)容,其實是很簡單的
param (
[parameter(Mandatory = $false)]
[Int]$MaxRecords = 100000,
[parameter(Mandatory = $true)]
[string]$User
)
function Write-DateTimeMessage {
param (
[parameter(Mandatory = $false)]
[switch]$Warning,
[parameter(Mandatory = $true)]
[string]$Message,
[parameter(Mandatory = $false)]
[string]$ForegroundColor
)
if ($Warning) {
Write-Warning ($(Get-Date -UFormat '%Y/%m/%d %H:%M:%S') + " * " + $Message)
}
else {
if ($ForegroundColor) {
Write-Host ($(Get-Date -UFormat '%Y/%m/%d %H:%M:%S') + " * " + $Message) -ForegroundColor $ForegroundColor
}
else {
Write-Host ($(Get-Date -UFormat '%Y/%m/%d %H:%M:%S') + " * " + $Message)
}
}
}
[pscustomobject[]]$UserObjects = $null
$Subscriptions = Get-AzureRmSubscription
foreach ($subscription in $Subscriptions) {
" "
"Querying Subscription:"
$SubscriptionID = $Subscription.Id
$SubscriptionName = $Subscription.Name
Select-AzureRmSubscription -SubscriptionId $SubscriptionID -InformationAction SilentlyContinue
Write-DateTimeMessage -Message "Retrieving logs, please wait..."
$logs = Get-AzureRmLog -ResourceProvider Microsoft.Compute -StartTime (Get-Date).AddDays(-90) -Maxrecord $MaxRecords
foreach ($log in $logs) {
if ($log.caller -eq $User) {
$UserObject = New-Object -TypeName psobject
$UserObject | Add-Member -MemberType NoteProperty -Name SubscriptionName -Value $SubscriptionName
$UserObject | Add-Member -MemberType NoteProperty -Name SubscriptionID -Value $SubscriptionID
$UserObject | Add-Member -MemberType NoteProperty -Name ResourceGroup -Value $log.ResourceGroupName
$UserObject | Add-Member -MemberType NoteProperty -Name Caller -Value $log.caller
$UserObject | Add-Member -MemberType NoteProperty -Name Operation -Value $log.OperationName.Value
$UserObject | Add-Member -MemberType NoteProperty -Name ResourceId -Value $log.ResourceId
$UserObject | Add-Member -MemberType NoteProperty -Name Time -Value $log.EventTimestamp
$UserObjects += $UserObject
}
}
}
$OutputPath = Join-Path -Path ([Environment]::GetFolderPath("Desktop")) -ChildPath ("AzureUserAction-" + $(Get-Date -Format "yyyyMMdd-HHmmss") + ".csv")
if ($null -ne $UserObjects) {
$UserObjects | Export-Csv -NoTypeInformation -LiteralPath $OutputPath
Write-DateTimeMessage -Message "Please check $OutputPath" -Warning
}
else {
Write-DateTimeMessage "Didn't get information, please check" -warning
}我們來嘗試著運行一下腳本Get-AzureUserActionLog.ps1 -User "xxx@xxx.partner.onmschina.cn", -User的作用是我們可以根據(jù)這個參數(shù)篩選出來特定的用戶

腳本執(zhí)行完成后,可以在桌面上看到一個csv文件,里邊會記錄查詢出來log

最后,還是要提醒一點,因為Azure后臺的限制,這只能查詢到最近90天之內(nèi)的log
感謝各位的閱讀!關于“怎么查詢Azure用戶操作記錄”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
網(wǎng)頁題目:怎么查詢Azure用戶操作記錄
網(wǎng)頁路徑:http://www.chinadenli.net/article8/iiieip.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設計、全網(wǎng)營銷推廣、外貿(mào)建站、網(wǎng)站設計公司、商城網(wǎng)站、App設計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)