Skip to content
Merged

3.6.5 #319

Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions AzureResourceInventory.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AzureResourceInventory.psm1'

# Version number of this module.
ModuleVersion = '3.6.4'
ModuleVersion = '3.6.5'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -33,7 +33,7 @@ Copyright = '(c) Claudio Merola. All rights reserved.'
Description = 'Azure Resource Inventory - Its a Powerful tool to create EXCEL inventory from Azure Resources with low effort'

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''
PowerShellVersion = '7.0'

# Name of the PowerShell host required by this module
# PowerShellHostName = ''
Expand Down
28 changes: 21 additions & 7 deletions Modules/Private/0.MainFunctions/Start-ARIProcessOrchestration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,29 @@ function Start-ARIProcessOrchestration {

<############################################################## RESOURCES PROCESSING #############################################################>

$JobNames = (Get-Job | Where-Object {$_.name -like 'ResourceJob_*'}).Name

if(![string]::IsNullOrEmpty($JobNames))
{
Wait-ARIJob -JobNames $JobNames -JobType 'Resource' -LoopTime 5

Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Finished Waiting for Resource Jobs.')

Build-ARICacheFiles -DefaultPath $DefaultPath -ReportCache $ReportCache -JobNames $JobNames
if ($Automation.IsPresent)
{
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Waiting for Resource Jobs to Complete in Automation Mode')
Get-Job | Where-Object {$_.name -like 'ResourceJob_*'} | Wait-Job
}
else
{
$JobNames = (Get-Job | Where-Object {$_.name -like 'ResourceJob_*'}).Name
Wait-ARIJob -JobNames $JobNames -JobType 'Resource' -LoopTime 5
}

if ($Automation.IsPresent)
{
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Processing Resources in Automation Mode')
}
else
{
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Finished Waiting for Resource Jobs.')
}

Build-ARICacheFiles -DefaultPath $DefaultPath -JobNames $JobNames
}

Write-Progress -activity 'Azure Inventory' -Status "60% Complete." -PercentComplete 60 -CurrentOperation "Completed Data Processing Phase.."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/1.ExtractionFunctions/Start-ARI
This powershell Module is part of Azure Resource Inventory (ARI)

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola

Expand Down Expand Up @@ -81,7 +81,7 @@ Function Start-ARIGraphExtraction {
}
}

$ExcludedTypes = "| where type !in ('microsoft.logic/workflows')"
$ExcludedTypes = "| where type !in ('microsoft.logic/workflows','microsoft.portal/dashboards','microsoft.resources/templatespecs/versions','microsoft.resources/templatespecs')"

$GraphQuery = "resources $RGQueryExtension $TagQueryExtension $MGQueryExtension $ExcludedTypes | project id,name,type,tenantId,kind,location,resourceGroup,subscriptionId,managedBy,sku,plan,properties,identity,zones,extendedLocation$($GraphQueryTags) | order by id asc"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Authors: Claudio Merola
#>

function Build-ARICacheFiles {
Param($DefaultPath, $ReportCache, $JobNames)
Param($DefaultPath, $JobNames)

Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Checking Cache Folder.')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Invoke-AR
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
Expand All @@ -22,7 +22,7 @@ function Invoke-ARIAdvisoryJob {

if ($Automation.IsPresent)
{
Write-Output ('Starting Advisory Job')
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Starting Advisory Job')
Start-ThreadJob -Name 'Advisory' -ScriptBlock {

import-module $($args[1])
Expand Down
4 changes: 2 additions & 2 deletions Modules/Private/2.ProcessingFunctions/Invoke-ARIPolicyJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Invoke-AR
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
Expand All @@ -22,7 +22,7 @@ function Invoke-ARIPolicyJob {

if ($Automation.IsPresent)
{
Write-Output ('Starting Policy Job')
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Starting Policy Job')
Start-ThreadJob -Name 'Policy' -ScriptBlock {

import-module $($args[4])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Invoke-AR
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
Expand All @@ -22,7 +22,7 @@ function Invoke-ARISecurityCenterJob {

if ($Automation.IsPresent)
{
Write-Output ('Starting SecurityCenter Job')
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Starting SecurityCenter Job')
Start-ThreadJob -Name 'Security' -ScriptBlock {

import-module $($args[2])
Expand Down
4 changes: 2 additions & 2 deletions Modules/Private/2.ProcessingFunctions/Invoke-ARISubJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Invoke-AR
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
Expand All @@ -22,7 +22,7 @@ function Invoke-ARISubJob {

if ($Automation.IsPresent)
{
Write-Output ('Starting Subscription Job')
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Starting Subscription Job')
Start-ThreadJob -Name 'Subscriptions' -ScriptBlock {

import-module $($args[2])
Expand Down
25 changes: 22 additions & 3 deletions Modules/Private/2.ProcessingFunctions/Start-ARIAutProcessJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Start-ARI
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
Expand All @@ -24,13 +24,15 @@ function Start-ARIAutProcessJob {
$InventoryModulesPath = Join-Path $ParentPath 'Public' 'InventoryModules'
$Modules = Get-ChildItem -Path $InventoryModulesPath -Directory
$NewResources = ($Resources | ConvertTo-Json -Depth 40 -Compress)
$SmaResources = @{} # Initialize the hashtable to store results
$JobLoop = 1
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+"Starting ARI Automation Processing Jobs...")

Foreach ($ModuleFolder in $Modules)
{
$ModulePath = Join-Path $ModuleFolder.FullName '*.ps1'
$ModuleName = $ModuleFolder.Name
$ModuleFiles = Get-ChildItem -Path $ModulePath
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+"Starting Job: $ModuleName")

Start-ThreadJob -Name ('ResourceJob_'+$ModuleName) -ScriptBlock {

Expand All @@ -40,6 +42,7 @@ function Start-ARIAutProcessJob {
$Resources = $($args[4]) | ConvertFrom-Json
$Retirements = $($args[5])
$Unsupported = $($args[10])
$SmaResources = @{} # Initialize the hashtable to store results

Foreach ($Module in $ModuleFiles)
{
Expand All @@ -58,6 +61,22 @@ function Start-ARIAutProcessJob {

$SmaResources

} -ArgumentList $ModuleFiles, $PSScriptRoot, $Subscriptions, $InTag, $NewResources, $Retirements, 'Processing', $null, $null, $null, $Unsupported -ThrottleLimit 8 | Out-Null
} -ArgumentList $ModuleFiles, $PSScriptRoot, $Subscriptions, $InTag, $NewResources, $Retirements, 'Processing', $null, $null, $null, $Unsupported | Out-Null

if($JobLoop -eq 4)
{
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Waiting Batch Jobs')

Get-Job | Where-Object {$_.name -like 'ResourceJob_*'} | Wait-Job

$JobNames = (Get-Job | Where-Object {$_.name -like 'ResourceJob_*'}).Name

Start-Sleep -Seconds 5

Build-ARICacheFiles -DefaultPath $DefaultPath -JobNames $JobNames

$JobLoop = 0
}
$JobLoop ++
}
}
4 changes: 2 additions & 2 deletions Modules/Private/2.ProcessingFunctions/Start-ARIProcessJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Private/2.ProcessingFunctions/Start-ARI
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
Expand Down Expand Up @@ -150,7 +150,7 @@ function Start-ARIProcessJob {

$JobNames = (Get-Job | Where-Object {$_.name -like 'ResourceJob_*'}).Name

Build-ARICacheFiles -DefaultPath $DefaultPath -ReportCache $ReportCache -JobNames $JobNames
Build-ARICacheFiles -DefaultPath $DefaultPath -JobNames $JobNames

$JobLoop = 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ function Build-ARIExcelChart {
}
Add-PivotTable @PTParams -NoLegend
}
else {
elseif ($Excel.Workbook.Worksheets | Where-Object { $_.Name -eq 'Virtual Machines' }) {
$P8Name = 'VMs per Region'
$PTParams = @{
PivotTableName = "P8"
Expand All @@ -761,6 +761,30 @@ function Build-ARIExcelChart {
}
Add-PivotTable @PTParams -NoLegend
}
else{
$P8Name = 'Resources per Region'
$PTParams = @{
PivotTableName = "P8"
Address = $excel.Overview.cells["DE5"] # top-left corner of the table
SourceWorkSheet = $excel.'Subscriptions'
PivotRows = @("Location")
PivotData = @{"Resources Count" = "Sum" }
PivotTableStyle = $tableStyle
IncludePivotChart = $true
ChartType = "BarStacked3D"
ChartRow = 34
ChartColumn = 24
Activate = $true
PivotFilter = 'Subscription'
ChartTitle = 'Resources by Location'
ShowPercent = $true
ChartHeight = 255
ChartWidth = 315
ChartRowOffSetPixels = 5
ChartColumnOffSetPixels = 0
}
Add-PivotTable @PTParams -NoLegend
}

$DrawP8 = $WS.Drawings | Where-Object { $_.Name -eq 'TP8' }
$DrawP8.RichText.Add($P8Name) | Out-Null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,60 @@ function Build-ARIExcelComObject {
$NoChangeChart = ('ChartP0', 'ChartP1', 'ChartP2', 'ChartP3', 'ChartP4', 'ChartP5', 'ChartP6', 'ChartP7', 'ChartP8', 'ChartP9', 'ARI', 'RGs', 'TP00', 'TP0', 'TP1', 'TP2', 'TP3', 'TP4', 'TP5','TP6','TP7','TP8','TP9')
$ChangeChart = ('ARI', 'RGs', 'TP00', 'TP0', 'TP1', 'TP2', 'TP3', 'TP4', 'TP5', 'TP6', 'TP7','TP8','TP9')

($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP0' }).DrawingObject.Chart.ChartStyle = 294
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP0' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP0' }).DrawingObject.Chart.ChartStyle = 294
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP1' }).DrawingObject.Chart.ChartStyle = 222
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP1' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP1' }).DrawingObject.Chart.ChartStyle = 222
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP2' }).DrawingObject.Chart.ChartStyle = 294
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP2' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP2' }).DrawingObject.Chart.ChartStyle = 294
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP3' }).DrawingObject.Chart.ChartStyle = 268
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP3' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP3' }).DrawingObject.Chart.ChartStyle = 268
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP4' }).DrawingObject.Chart.ChartStyle = 294
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP4' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP4' }).DrawingObject.Chart.ChartStyle = 294
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP5' }).DrawingObject.Chart.ChartStyle = 222
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP5' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP5' }).DrawingObject.Chart.ChartStyle = 222
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP6' }).DrawingObject.Chart.ChartStyle = 294
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP6' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP6' }).DrawingObject.Chart.ChartStyle = 294
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP7' }).DrawingObject.Chart.ChartStyle = 268
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP7' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP7' }).DrawingObject.Chart.ChartStyle = 268
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP8' }).DrawingObject.Chart.ChartStyle = 294
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP8' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP8' }).DrawingObject.Chart.ChartStyle = 294
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP9' }).DrawingObject.Chart.ChartStyle = 268
if ($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP9' })
{
($WSheet.Shapes | Where-Object { $_.name -eq 'ChartP9' }).DrawingObject.Chart.ChartStyle = 268
}
Start-Sleep -Milliseconds 50
($WSheet.Shapes | Where-Object { $_.name -notin $NoChangeChart -and $_.name -like 'Chart*' }).DrawingObject.Chart.ChartStyle = 315
if ($WSheet.Shapes | Where-Object { $_.name -notin $NoChangeChart -and $_.name -like 'Chart*' })
{
($WSheet.Shapes | Where-Object { $_.name -notin $NoChangeChart -and $_.name -like 'Chart*' }).DrawingObject.Chart.ChartStyle = 315
}
Start-Sleep -Milliseconds 50

Foreach ($Changer in $ChangeChart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Public/PublicFunctions/Diagram/Start-AR
This PowerShell Module is part of Azure Resource Inventory (ARI)

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola

Expand Down Expand Up @@ -84,7 +84,7 @@ Function Start-ARIDiagramJob {

$Variables

} -ArgumentList $resources, $null
} -ArgumentList $resources, $null | Out-Null
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://github.com/microsoft/ARI/Modules/Public/PublicFunctions/Diagram/Start-AR
This PowerShell Module is part of Azure Resource Inventory (ARI)

.NOTES
Version: 3.6.0
Version: 3.6.5
First Release Date: 15th Oct, 2024
Authors: Claudio Merola

Expand Down Expand Up @@ -63,7 +63,7 @@ function Start-ARIDrawIODiagram {
{
('DrawIOCoreFile - '+(get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - Error: ' + $_.Exception.Message) | Out-File -FilePath $($args[3]) -Append
}
} -ArgumentList $Subscriptions, $Resources, $DiagramCache, $Logfile
} -ArgumentList $Subscriptions, $Resources, $DiagramCache, $Logfile | Out-Null
}
else
{
Expand Down Expand Up @@ -94,7 +94,7 @@ function Start-ARIDrawIODiagram {
{
('DrawIOCoreFile - '+(get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - Error: ' + $_.Exception.Message) | Out-File -FilePath $($args[2]) -Append
}
} -ArgumentList $ResourceContainers, $DiagramCache, $Logfile
} -ArgumentList $ResourceContainers, $DiagramCache, $Logfile | Out-Null
}
else
{
Expand Down Expand Up @@ -133,7 +133,7 @@ function Start-ARIDrawIODiagram {
{
('DrawIOCoreFile - '+(get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - Error: ' + $_.Exception.Message) | Out-File -FilePath $($args[7]) -Append
}
} -ArgumentList $Subscriptions, $Job, $Advisories, $DiagramCache, $FullEnvironment, $DDFile, $XMLFiles, $Logfile, $Automation
} -ArgumentList $Subscriptions, $Job, $Advisories, $DiagramCache, $FullEnvironment, $DDFile, $XMLFiles, $Logfile, $Automation | Out-Null
}
else
{
Expand Down
Loading