Skip to content
Closed
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 @@ -12,15 +12,15 @@ https://github.com/microsoft/ARI/Modules/Private/0.MainFunctions/Start-ARIExtrac
This PowerShell Module is part of Azure Resource Inventory (ARI)

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

#>
function Start-ARIExtractionOrchestration {
Param($ManagementGroup, $Subscriptions, $SubscriptionID, $SkipPolicy, $ResourceGroup, $SecurityCenter, $SkipAdvisory, $IncludeTags, $TagKey, $TagValue, $SkipAPIs, $SkipVMDetails, $IncludeCosts, $Automation)
Param($ManagementGroup, $Subscriptions, $SubscriptionID, $SkipPolicy, $ResourceGroup, $SecurityCenter, $SkipAdvisory, $IncludeTags, $TagKey, $TagValue, $SkipAPIs, $SkipVMDetails, $IncludeCosts, $Automation, $AzureEnvironment)

$GraphData = Start-ARIGraphExtraction -ManagementGroup $ManagementGroup -Subscriptions $Subscriptions -SubscriptionID $SubscriptionID -ResourceGroup $ResourceGroup -SecurityCenter $SecurityCenter -SkipAdvisory $SkipAdvisory -IncludeTags $IncludeTags -TagKey $TagKey -TagValue $TagValue
$GraphData = Start-ARIGraphExtraction -ManagementGroup $ManagementGroup -Subscriptions $Subscriptions -SubscriptionID $SubscriptionID -ResourceGroup $ResourceGroup -SecurityCenter $SecurityCenter -SkipAdvisory $SkipAdvisory -IncludeTags $IncludeTags -TagKey $TagKey -TagValue $TagValue -AzureEnvironment $AzureEnvironment

$Resources = $GraphData.Resources
$ResourceContainers = $GraphData.ResourceContainers
Expand Down
46 changes: 18 additions & 28 deletions Modules/Private/1.ExtractionFunctions/Get-ARIManagementGroups.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,36 @@ https://github.com/microsoft/ARI/Modules/Private/1.ExtractionFunctions/Get-ARIMa
This PowerShell Module is part of Azure Resource Inventory (ARI).

.NOTES
Version: 3.6.0
Version: 3.6.11
First Release Date: 15th Oct, 2024
Authors: Claudio Merola
#>
function Get-ARIManagementGroups {
Param ($ManagementGroup)
Param ($ManagementGroup,$Subscriptions)

Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Management group name supplied: ' + $ManagmentGroupName)
$ReportCounter = 1
$LocalResults = @()
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Management group name: ' + $ManagementGroup)

$group = Get-AzManagementGroupEntity
$group = $group | Where-Object { $_.DisplayName -eq $ManagementGroup }
if ($group.Count -lt 1)
{
$GraphQuery = "resourcecontainers | where type == 'microsoft.resources/subscriptions' | mv-expand managementGroupParent = properties.managementGroupAncestorsChain | where managementGroupParent.name =~ '$($ManagementGroup)'"
$QueryResult = Search-AzGraph -Query $GraphQuery -first 1000 -Debug:$false
$LocalResults = $QueryResult

if ($LocalResults.Count -lt 1) {
Write-Host "ERROR:" -NoNewline -ForegroundColor Red
Write-Host "Management Group $ManagementGroup not found!"
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
}
else
{
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Management groups found: ' + $group.count)
foreach ($item in $group)
{
$GraphQuery = "resourcecontainers | where type == 'microsoft.resources/subscriptions' | mv-expand managementGroupParent = properties.managementGroupAncestorsChain | where managementGroupParent.name =~ '$($item.DisplayName)'"
$QueryResult = Search-AzGraph -Query $GraphQuery -first 1000
$LocalResults += $QueryResult

while ($QueryResult.SkipToken) {
$ReportCounterVar = [string]$ReportCounter
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Extracting Next 1000 Subscriptions. Loop Number: ' + $ReportCounterVar)
$QueryResult = Search-AzGraph -Query $GraphQuery -SkipToken $QueryResult.SkipToken -Subscription $FSubscri -first 1000
$LocalResults += $QueryResult
$ReportCounter ++
else {
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Subscriptions found for Management Group: ' + $LocalResults.Count)
$FinalSubscriptions = foreach ($Sub in $Subscriptions)
{
if ($Sub.name -in $LocalResults.name)
{
$Sub
}
}
Write-Progress -Id 1 -activity "Running Subscription Inventory Job" -Status "$Looper / $Loop of Subscription Jobs" -Completed
}
}
return $LocalResults
return $FinalSubscriptions
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ 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.5
Version: 3.6.11
First Release Date: 15th Oct, 2024
Authors: Claudio Merola

#>
Function Start-ARIGraphExtraction {
Param($ManagementGroup, $Subscriptions, $SubscriptionID, $ResourceGroup, $SecurityCenter, $SkipAdvisory, $IncludeTags, $TagKey, $TagValue)
Param($ManagementGroup, $Subscriptions, $SubscriptionID, $ResourceGroup, $SecurityCenter, $SkipAdvisory, $IncludeTags, $TagKey, $TagValue, $AzureEnvironment)

Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Starting Extractor function')

Expand All @@ -40,7 +40,7 @@ Function Start-ARIGraphExtraction {

if (![string]::IsNullOrEmpty($ManagementGroup))
{
$Subscriptions = Get-ARIManagementGroups -ManagementGroup $ManagementGroup
$Subscriptions = Get-ARIManagementGroups -ManagementGroup $ManagementGroup -Subscriptions $Subscriptions
}

$SubCount = [string]$Subscriptions.id.count
Expand Down Expand Up @@ -104,10 +104,13 @@ Function Start-ARIGraphExtraction {
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Invoking Inventory Loop for Network Resources')
$Resources += Invoke-ARIInventoryLoop -GraphQuery $GraphQuery -FSubscri $Subscri -LoopName 'Network Resources'

$GraphQuery = "SupportResources $RGQueryExtension $TagQueryExtension $MGQueryExtension | project id,name,type,tenantId,kind,location,resourceGroup,subscriptionId,managedBy,sku,plan,properties,identity,zones,extendedLocation$($GraphQueryTags) | order by id asc"
if ($AzureEnvironment -ne 'AzureUSGovernment')
{
$GraphQuery = "SupportResources $RGQueryExtension $TagQueryExtension $MGQueryExtension | project id,name,type,tenantId,kind,location,resourceGroup,subscriptionId,managedBy,sku,plan,properties,identity,zones,extendedLocation$($GraphQueryTags) | order by id asc"

Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Invoking Inventory Loop for Support Tickets')
$Resources += Invoke-ARIInventoryLoop -GraphQuery $GraphQuery -FSubscri $Subscri -LoopName 'SupportTickets'
Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Invoking Inventory Loop for Support Tickets')
$Resources += Invoke-ARIInventoryLoop -GraphQuery $GraphQuery -FSubscri $Subscri -LoopName 'SupportTickets'
}

$GraphQuery = "recoveryservicesresources $RGQueryExtension $TagQueryExtension | where type =~ 'microsoft.recoveryservices/vaults/backupfabrics/protectioncontainers/protecteditems' or type =~ 'microsoft.recoveryservices/vaults/backuppolicies' $MGQueryExtension | project id,name,type,tenantId,kind,location,resourceGroup,subscriptionId,managedBy,sku,plan,properties,identity,zones,extendedLocation$($GraphQueryTags) | order by id asc"

Expand Down
3 changes: 2 additions & 1 deletion Modules/Public/InventoryModules/AI/AzureAI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Else
if($SmaResources)
{

$TableName = ('AzureAITable_'+($SmaResources.'Resource U').count)
$TableName = ('AzureAITable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,6 +143,7 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
Expand Down
3 changes: 2 additions & 1 deletion Modules/Public/InventoryModules/AI/ComputerVision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Else
if($SmaResources)
{

$TableName = ('VisionTable_'+($SmaResources.'Resource U').count)
$TableName = ('VisionTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,6 +143,7 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
Expand Down
3 changes: 2 additions & 1 deletion Modules/Public/InventoryModules/AI/ContentModerator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Else
if($SmaResources)
{

$TableName = ('ContentModTb_'+($SmaResources.'Resource U').count)
$TableName = ('ContentModTb_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -142,6 +142,7 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
Expand Down
3 changes: 2 additions & 1 deletion Modules/Public/InventoryModules/AI/ContentSafety.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Else
if($SmaResources)
{

$TableName = ('ContSafTable_'+($SmaResources.'Resource U').count)
$TableName = ('ContSafTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,6 +143,7 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
Expand Down
3 changes: 2 additions & 1 deletion Modules/Public/InventoryModules/AI/CustomVision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Else
if($SmaResources)
{

$TableName = ('CustomViTable_'+($SmaResources.'Resource U').count)
$TableName = ('CustomViTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -145,6 +145,7 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/FaceAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Else
if($SmaResources)
{

$TableName = ('FaceAPITable_'+($SmaResources.'Resource U').count)
$TableName = ('FaceAPITable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,9 +143,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Face API' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/FormRecognizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Else
if($SmaResources)
{

$TableName = ('DocIntTable_'+($SmaResources.'Resource U').count)
$TableName = ('DocIntTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,9 +143,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Doc Intelligence' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/HealthInsights.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Else
if($SmaResources)
{

$TableName = ('HealthInsTable_'+($SmaResources.'Resource U').count)
$TableName = ('HealthInsTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -148,9 +148,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Health Insights' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/ImmersiveReader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Else
if($SmaResources)
{

$TableName = ('ImmersiveRTable_'+($SmaResources.'Resource U').count)
$TableName = ('ImmersiveRTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,9 +143,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Immersive Reader' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/MachineLearning.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Else {

if ($SmaResources) {

$TableName = ('AzureMLTable_'+($SmaResources.'Resource U').count)
$TableName = ('AzureMLTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat 0

$condtxt = @()
Expand Down Expand Up @@ -143,9 +143,10 @@ Else {
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Machine Learning' -AutoSize -MaxAutoSizeRows 100 -TableName $TableName -TableStyle $tableStyle -ConditionalText $condtxt -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/SearchServices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Else
if($SmaResources)
{

$TableName = ('SearchTable_'+($SmaResources.'Resource U').count)
$TableName = ('SearchTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -144,9 +144,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Search Services' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/SpeechService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Else
if($SmaResources)
{

$TableName = ('SpeechTable_'+($SmaResources.'Resource U').count)
$TableName = ('SpeechTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -143,9 +143,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Speech Service' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
7 changes: 4 additions & 3 deletions Modules/Public/InventoryModules/AI/TextAnalytics.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Else
if($SmaResources)
{

$TableName = ('LanguTable_'+($SmaResources.'Resource U').count)
$TableName = ('LanguTable_'+(($SmaResources.'Resource U' | Measure-Object -Sum).Sum))
$Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat '0'

$condtxt = @()
Expand Down Expand Up @@ -142,9 +142,10 @@ Else
$Exc.Add('Tag Name')
$Exc.Add('Tag Value')
}
$Exc.Add('Resource U')

[PSCustomObject]$SmaResources |
ForEach-Object { $_ } | Select-Object $Exc |
$SmaResources |
ForEach-Object { [PSCustomObject]$_ } | Select-Object $Exc |
Export-Excel -Path $File -WorksheetName 'Language' -AutoSize -MaxAutoSizeRows 100 -ConditionalText $condtxt -TableName $TableName -TableStyle $tableStyle -Style $Style

}
Expand Down
Loading