Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ function Get-ARIManagementGroups {
$LocalResults = $QueryResult

if ($LocalResults.Count -lt 1) {
Write-Host "ERROR:" -NoNewline -ForegroundColor Red
Write-Host "No Subscriptions found for Management Group: $ManagementGroup!"
Write-Host ""
Write-Host "Please check the Management Group name and try again."
Write-Host ""
Exit
throw "No Subscriptions found for Management Group: $ManagementGroup! Please check the Management Group name and try again."
}
else {
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Subscriptions found for Management Group: ' + $LocalResults.Count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ Function Start-ARIGraphExtraction {
if(![string]::IsNullOrEmpty($ResourceGroup) -and [string]::IsNullOrEmpty($SubscriptionID))
{
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Resource Group Name present, but missing Subscription ID.')
Write-Output ''
Write-Output 'If Using the -ResourceGroup Parameter, the Subscription ID must be informed'
Write-Output ''
Exit
throw 'If Using the -ResourceGroup Parameter, the Subscription ID must be informed'
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Authors: Claudio Merola
#>

function Invoke-ARISecurityCenterJob {
Param($Subscriptions, $Automation, $Resources, $ARIModule)
Param($Subscriptions, $Automation, $Resources, $SecurityCenter, $ARIModule)

if ($Automation.IsPresent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Start-ARIAutProcessJob {
$JobLoop = 1
Write-Output ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+"Starting ARI Automation Processing Jobs...")

if ($Heavy.IsPresent -or $InTag.IsPresent)
if ($Heavy -or $InTag)
{
Write-Output ('Heavy Mode Detected. Jobs will be run in small batches to avoid CPU and Memory Overload.')
$EnvSizeLooper = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Start-ARIExtraJobs {
$IncludeCosts,
$CostData)

$ARIModule = 'AzureResourceInventory'
$ARIModule = Join-Path $MyInvocation.MyCommand.Module.ModuleBase 'AzureResourceInventory.psd1'
#$ARIModule = 'C:\usr\src\PSModules\AzureResourceInventory\AzureResourceInventory'

<######################################################### DRAW IO DIAGRAM JOB ######################################################################>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Start-ARIProcessJob {
}
}

if ($Heavy.IsPresent -or $InTag.IsPresent)
if ($Heavy -or $InTag)
{
Write-Host ('Heavy Mode or InTag Mode Detected. Jobs will be run in small batches to avoid CPU and Memory Overload.') -ForegroundColor Red
$EnvSizeLooper = 5
Expand Down
70 changes: 7 additions & 63 deletions Modules/Public/PublicFunctions/Invoke-ARI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Use this parameter to include Quota information

.PARAMETER IncludeTags
Use this parameter to include Tags of every Azure Resources
Use this parameter to include Tags of every Azure Resources. Each tag is written as its own row, and Heavy mode batching is enabled automatically to limit memory use.

.PARAMETER Debug
Output detailed debug information.
Expand Down Expand Up @@ -125,7 +125,7 @@ Function Invoke-ARI {
param (
[ValidateSet(1, 2, 3)]
[int]$Overview = 1,
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud', 'AzureGermanCloud')]
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
[string]$AzureEnvironment = 'AzureCloud',
[string]$TenantID,
[string]$AppId,
Expand Down Expand Up @@ -188,8 +188,7 @@ Function Invoke-ARI {
$RunLite = $true
if (!$StorageAccount -or !$StorageContainer)
{
Write-Output "Storage Account and Container are required for Automation mode. Aborting."
exit
throw "Storage Account and Container are required for Automation mode. Aborting."
}
}
if ($Overview -eq 1 -and $SkipAPIs)
Expand All @@ -198,65 +197,11 @@ Function Invoke-ARI {
}
$TableStyle = "Light19"

<######################################################### Help ######################################################################>

Function Get-ARIUsageMode() {
Write-Host ""
Write-Host "Parameters"
Write-Host ""
Write-Host " -TenantID <ID> : Specifies the Tenant to be inventoried. "
Write-Host " -SubscriptionID <ID> : Specifies Subscription(s) to be inventoried. "
Write-Host " -ResourceGroup <NAME> : Specifies one (or more) unique Resource Group to be inventoried, This parameter requires the -SubscriptionID to work. "
Write-Host " -AppId <ID> : Specifies the ApplicationID that is used to connect to Azure as service principal. This parameter requires the -TenantID and -Secret to work. "
Write-Host " -Secret <VALUE> : Specifies the Secret that is used with the Application ID to connect to Azure as service principal. This parameter requires the -TenantID and -AppId to work. If -CertificatePath is also used the Secret value should be the Certifcate password instead of the Application secret. "
Write-Host " -CertificatePath <PATH> : Specifies the Certificate path that is used with the Application ID to connect to Azure as service principal. This parameter requires the -TenantID, -AppId and -Secret to work. The required certificate format is pkcs#12. "
Write-Host " -TagKey <NAME> : Specifies the tag key to be inventoried, This parameter requires the -SubscriptionID to work. "
Write-Host " -TagValue <NAME> : Specifies the tag value be inventoried, This parameter requires the -SubscriptionID to work. "
Write-Host " -SkipAdvisory : Do not collect Azure Advisory. "
Write-Host " -SkipPolicy : Do not collect Azure Policies. "
Write-Host " -SecurityCenter : Include Security Center Data. "
Write-Host " -IncludeTags : Include Resource Tags. "
Write-Host " -Online : Use Online Modules. "
Write-Host " -Debug : Run in a Debug mode. "
Write-Host " -AzureEnvironment : Change the Azure Cloud Environment. "
Write-Host " -ReportName : Change the Default Name of the report. "
Write-Host " -ReportDir : Change the Default Path of the report. "
Write-Host ""
Write-Host ""
Write-Host ""
Write-Host "Usage Mode and Examples: "
Write-Host "If you do not specify Resource Inventory will be performed on all subscriptions for the selected tenant. "
Write-Host "e.g. /> Invoke-ARI"
Write-Host ""
Write-Host "To perform the inventory in a specific Tenant and subscription use <-TenantID> and <-SubscriptionID> parameter "
Write-Host "e.g. /> Invoke-ARI -TenantID <Azure Tenant ID> -SubscriptionID <Subscription ID>"
Write-Host ""
Write-Host "Including Tags:"
Write-Host " By Default Azure Resource inventory do not include Resource Tags."
Write-Host " To include Tags at the inventory use <-IncludeTags> parameter. "
Write-Host "e.g. /> Invoke-ARI -TenantID <Azure Tenant ID> -IncludeTags"
Write-Host ""
Write-Host "Skipping Azure Advisor:"
Write-Host " By Default Azure Resource inventory collects Azure Advisor Data."
Write-Host " To ignore this use <-SkipAdvisory> parameter. "
Write-Host "e.g. /> Invoke-ARI -TenantID <Azure Tenant ID> -SubscriptionID <Subscription ID> -SkipAdvisory"
Write-Host ""
Write-Host "Using the latest modules :"
Write-Host " You can use the latest modules. For this use <-Online> parameter."
Write-Host " It's a pre-requisite to have internet access for ARI GitHub repo"
Write-Host "e.g. /> Invoke-ARI -TenantID <Azure Tenant ID> -Online"
Write-Host ""
Write-Host "Running in Debug Mode :"
Write-Host " To run in a Debug Mode use <-Debug> parameter."
Write-Host ".e.g. /> Invoke-ARI -TenantID <Azure Tenant ID> -Debug"
Write-Host ""
}

$TotalRunTime = [System.Diagnostics.Stopwatch]::StartNew()

if ($Help.IsPresent) {
Get-ARIUsageMode
Exit
Get-Help Invoke-ARI -Full
return
}

$PlatOS = Test-ARIPS
Expand Down Expand Up @@ -289,8 +234,7 @@ Function Invoke-ARI {
Set-AzContext -SubscriptionName $AzureConnection.Subscription -DefaultProfile $AzureConnection
}
catch {
Write-Output "Failed to set Automation Account requirements. Aborting."
exit
throw "Failed to set Automation Account requirements. Aborting. $_"
}
}

Expand Down Expand Up @@ -455,7 +399,7 @@ Function Invoke-ARI {
Write-Output "Sending Diagram file to Storage Account:"
Write-Output $DDFile
Set-AzStorageBlobContent -File $DDFile -Container $StorageContainer -Context $StorageContext | Out-Null
if($Debug.IsPresent)
if($PSBoundParameters.ContainsKey('Debug'))
{
$LogFilePath = Join-Path $DefaultPath 'DiagramLogFile.log'
Set-AzStorageBlobContent -File $LogFilePath -Container $StorageContainer -Context $StorageContext -Force | Out-Null
Expand Down
5 changes: 2 additions & 3 deletions Modules/Public/PublicFunctions/Invoke-AzureRAMPInventory.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function Invoke-AzureRAMPInventory {
[CmdletBinding(PositionalBinding=$false)]
param (
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud', 'AzureGermanCloud')]
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
[string]$AzureEnvironment = 'AzureCloud',
[string]$TenantID,
[string]$AppId,
Expand Down Expand Up @@ -38,8 +38,7 @@ function Invoke-AzureRAMPInventory {
Set-AzContext -SubscriptionName $AzureConnection.Subscription -DefaultProfile $AzureConnection
}
catch {
Write-Output "Failed to set Automation Account requirements. Aborting."
exit
throw "Failed to set Automation Account requirements. Aborting. $_"
}
}

Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ To speed up report generation:

The `-IncludeTags` parameter includes all resource tags in the report. This is useful for environments that use tagging extensively for organization or governance.

Each tag is written as its own row, so a resource with 10 tags appears on 10 rows. Because this increases memory use, `-IncludeTags` automatically enables the same small-batch processing as `-Heavy`. Expect longer run times.

### Can I run ARI without an internet connection?

No, ARI needs to connect to Azure APIs to collect resource information.
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Azure Resource Inventory (ARI) offers a wide range of parameters to customize yo
| Parameter | Description | Example |
|-----------|-------------|---------|
| **SecurityCenter** | Include Security Center data | `-SecurityCenter` |
| **IncludeTags** | Include resource tags | `-IncludeTags` |
| **IncludeTags** | Include resource tags (one row per tag; also enables Heavy mode batching, so runs take longer) | `-IncludeTags` |
| **SkipPolicy** | Skip Azure Policy collection | `-SkipPolicy` |
| **SkipVMDetails** | Skip Azure VM Extra Details collection | `-SkipVMDetails` |
| **SkipAdvisory** | Skip Azure Advisory collection | `-SkipAdvisory` |
Expand Down