Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AzureResourceInventory.ps1 #170

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update AzureResourceInventory.ps1
add billing section for the the billing module Extras\Billing.ps1
  • Loading branch information
manuel-beck committed Feb 27, 2024
commit 82b8edec1621336f27ea440b091d380fbd1c4c3d
45 changes: 45 additions & 0 deletions AzureResourceInventory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,46 @@ param ($TenantID,

Write-Progress -activity 'Azure Resource Inventory Subscriptions' -Status "100% Complete." -Completed

<################################################ BILLING #######################################################>

Write-Debug ('Checking If Should Run Billing.')
if ($Billing.IsPresent)
{
Write-Debug ('Generating Billing Report.')
$Global:Bilco = $Billing.Count

$Bil = Receive-Job -Name 'Billing'
Write-Debug ('Starting Billing Job.')
If ($RunOnline -eq $true) {
Write-Debug ('Looking for the following file: '+$RawRepo + '/Extras/Billing.ps1')
$ModuSeq = (New-Object System.Net.WebClient).DownloadString($RawRepo + '/Extras/Billing.ps1')
}
Else {
if($PSScriptRoot -like '*\*')
{
Write-Debug ('Looking for the following file: '+$PSScriptRoot + '\Extras\Billing.ps1')
$ModuSeq0 = New-Object System.IO.StreamReader($PSScriptRoot + '\Extras\Billing.ps1')
}
else
{
Write-Debug ('Looking for the following file: '+$PSScriptRoot + '/Extras/Billing.ps1')
$ModuSeq0 = New-Object System.IO.StreamReader($PSScriptRoot + '/Extras/Billing.ps1')
}
$ModuSeq = $ModuSeq0.ReadToEnd()
$ModuSeq0.Dispose()
}

$BilExcelRun = ([PowerShell]::Create()).AddScript($ModuSeq).AddArgument($($SubscriptionID)).AddArgument($null).AddArgument('Billing').AddArgument($file).AddArgument($Bil).AddArgument($TableStyle)
$BilExcelJob = $BilExcelRun.BeginInvoke()

while ($BilExcelJob.IsCompleted -contains $false) { Start-Sleep -Milliseconds 100 }
$BilExcelRun.EndInvoke($BilExcelJob)
$BilExcelRun.Dispose()

Write-Progress -activity 'Azure Resource Inventory Billing' -Status "100% Complete." -Completed

}

<################################################################### CHARTS ###################################################################>

Write-Debug ('Generating Overview sheet (Charts).')
Expand Down Expand Up @@ -1785,6 +1825,11 @@ if ($SecurityCenter.IsPresent)
Write-Host ('Total Security Advisories: ' + $Secadvco)
}

if ($Billing.IsPresent)
{
Write-Host ('Total Billing: ' + $Bilco)
}

Write-Host ''
Write-Host ('Excel file saved at: ') -NoNewline
write-host $File -ForegroundColor Cyan
Expand Down