有沒有辦法使用 powershell 來獲取 Azure 檔案共享的大小?
我可以使用 Get-AzStorageShare 來提取 etag、配額、層等,但我似乎無法找到從哪里獲取“使用情況”。
我可以在傳送門中看到它,所以它一定來自某個地方……

uj5u.com熱心網友回復:
從 Azure PowerShell 7.5 版開始,Az.Storage模塊中沒有可直接為您提供此資訊的 Cmdlet。
但是,有一種解決方法。
這個想法是呼叫Get-AzStorageSharewhich 會給你一個型別的物件AzureStorageFileShare。此物件有一個名為的屬性ShareClient,可在 Azure 存盤檔案 SDK 中使用。一旦您有權訪問此物件,您就可以呼叫GetStatistics方法來獲取共享使用情況。
$accountName = "your storage account name"
$accountKey = "your storage account key"
$shareName = "your share name"
$ctx = New-AzStorageContext -StorageAccountName $accountName -StorageAccountKey $accountKey
$share = Get-AzStorageShare -Name $shareName
$client = $share.ShareClient
# We now have access to Azure Storage SDK and we can call any method available in the SDK.
# Get statistics of the share
$stats = $client.GetStatistics()
$shareUsageInBytes = $stats.Value.ShareUsageInBytes
Write-Host $shareUsageInBytes
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/477599.html
