Skip to content

Commit

Permalink
Merge pull request #3 from JCoreMS/JCore-AVDAlerts-Issue221
Browse files Browse the repository at this point in the history
chore: Update Get-StorAcctInfo.ps1 script for Azure Files Storage dat…
  • Loading branch information
JCoreMS authored Jun 28, 2024
2 parents 8dbab6e + 8f266b5 commit 8c1fb67
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions patterns/avd/scripts/Get-StorAcctInfo.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Deployed from resources.bicep
# Deployed from resources.bicep
# Code for Runbook associated with Action Account deployment
# Collects Azure Files Storage data and writes output in following format:
# AzFiles, Subscription ,RG ,StorAcct ,Share ,Quota ,GB Used ,%Available

<#
//Kusto Query for Log Analtyics
AzureDiagnostics
AzureDiagnostics
| where Category has "JobStreams"
| where StreamType_s has "Output"
| extend Results=split(ResultDescription,',')
Expand All @@ -27,11 +27,11 @@ $SubName = (Get-azSubscription -SubscriptionId ($StorageAccountResourceIDs -spli

# Foreach storage account
Foreach ($storageAcct in $storageAccountResourceIDs) {

$resourceGroup = ($storageAcct -split '/')[4]
$storageAcctName = ($storageAcct -split '/')[8]
#Write-Host "Working on Storage:" $storageAcctName "in" $resourceGroup

# $shares = Get-AzStorageShare -ResourceGroupName $resourceGroup -StorageAccountName $storageAcctName -Name 'profiles' -GetShareUsage
$shares = Get-AzRmStorageShare -ResourceGroupName $ResourceGroup -StorageAccountName $storageAcctName

Expand All @@ -42,13 +42,13 @@ Foreach ($storageAcct in $storageAccountResourceIDs) {
#Write-Host "Share: " $shareName
$shareQuota = $share.QuotaGiB #GB
$shareUsageInGB = $share.ShareUsageBytes / 1073741824 # Bytes to GB
$RemainingPercent = 100 - ($shareUsageInGB / $shareQuota)

$RemainingPercent = 100 - ($shareUsageInGB / $shareQuota * 100)
#Write-Host "..." $shareUsageInGB "of" $shareQuota "GB used"
#Write-Host "..." $RemainingPercent "% Available"
# Add file share resource Id
$shareResourceId = $share.Id
# Compile results
# Compile results
# AzFiles / Subscription / RG / StorAcct / Share / Quota / GB Used / %Available
$Data = @('AzFiles', $SubName, $resourceGroup, $storageAcctName, $shareName, $shareQuota.ToString(), $shareUsageInGB.ToString(), $RemainingPercent.ToString(), $shareResourceId)
$i = 0
Expand Down

0 comments on commit 8c1fb67

Please sign in to comment.