Home > Software design >  The following Code snippet doesn't return ShareUsageBytes
The following Code snippet doesn't return ShareUsageBytes

Time:03-23

Get-AzRmStorageShare -ResourceGroupName "ResourceGroup" -StorageAccountName "StorageAccount" -GetShareUsage

This is the code I am using, but with stand-ins for the actual RG and SAN name. this is the output I get

Name                          QuotaGiB EnabledProtocols AccessTier Deleted Version ShareUsageBytes snapshotTime
----                          -------- ---------------- ---------- ------- ------- --------------- ------------
name1                         100      SMB              Premium
name2                         100      SMB              Premium
name3                         100      SMB              Premium
name4                         100      SMB              Premium
name5                         100      SMB              Premium

So despite the fact that i invoked the specific argument to pull ShareUsageBytes in -GetShareUsage it doesnt actually output that to the column despite outputting all other correct info. i feel like I'm going crazy because I'm not sure what I'm doing wrong.

CodePudding user response:

I believe you will only be able to get share usage when you get the details of a single file share i.e. -GetShareUsage will only work when -Name parameter is specified.

This is based on the source code here:

if (!string.IsNullOrEmpty(this.Name))
{
    string expend = null;
    if(this.GetShareUsage)
    {
        expend = ShareGetExpand.Stats;
    }
    var Share = this.StorageClient.FileShares.Get(
               this.ResourceGroupName,
               this.StorageAccountName,
               this.Name,
               expend,
               xMsSnapshot: this.SnapshotTime is null? null : this.SnapshotTime.Value.ToUniversalTime().ToString("o"));
    WriteObject(new PSShare(Share));
}
  • Related