Skip to content

Commit 5ab93c6

Browse files
committed
Added example for Bucket Accounting to Tutorial
1 parent 9d417bd commit 5ab93c6

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

StorageGRID-Webscale-Tutorial.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,28 @@ Connect-SGWServer -Name $Server -Credential $Credential -HTTP
6060

6161
## Simple workflow for exporting S3 account usage to CSV
6262

63-
In this simple workflow the S3 account usage data will be retrieved and exported as CSV to [C:\tmp\usage.csv](C:\tmp\usage.csv).
63+
In this simple workflow the S3 account usage data will be retrieved and exported as CSV to [$HOME\Downloads\TenantAccounting.csv]($HOME\Downloads\TenantAccounting.csv).
6464

6565
```powershell
66-
$Accounting = foreach ($Account in (Get-SGWAccounts | Where-Object { $_.capabilities -match "s3" })) {
66+
$TenantAccounting = foreach ($Account in (Get-SGWAccounts | Where-Object { $_.capabilities -match "s3" })) {
6767
$Usage = $Account | Get-SGWAccountUsage
6868
$Output = New-Object -TypeName PSCustomObject -Property @{Name=$Account.name;ID=$Account.id;"Calculation Time"=$Usage.calculationTime;"Object Count"=$Usage.objectCount;"Data Bytes used"=$Usage.dataBytes}
6969
Write-Output $Output
7070
}
7171
72-
$Accounting | Export-Csv -Path C:\tmp\usage.csv -NoTypeInformation
72+
$TenantAccounting | Export-Csv -Path $HOME\Downloads\TenantAccounting.csv -NoTypeInformation
7373
```
74+
75+
The next workflow will retrieve the S3 Account usage per Bucket and export it as CSV to [$HOME\Downloads\BucketAccounting.csv]($HOME\Downloads\BucketAccounting.csv)
76+
77+
```powershell
78+
$BucketAccounting = foreach ($Account in (Get-SGWAccounts | Where-Object { $_.capabilities -match "s3" })) {
79+
$Usage = $Account | Get-SGWAccountUsage
80+
foreach ($Bucket in $Usage.Buckets) {
81+
$Output = New-Object -TypeName PSCustomObject -Property @{Name=$Account.name;ID=$Account.id;"Calculation Time"=$Usage.calculationTime;Bucket=$Bucket.Name;"Object Count"=$Bucket.objectCount;"Data Bytes used"=$Bucket.dataBytes}
82+
Write-Output $Output
83+
}
84+
}
85+
86+
$BucketAccounting | Export-Csv -Path $HOME\Downloads\TenantAccounting.csv -NoTypeInformation
87+
```

0 commit comments

Comments
 (0)