Skip to content

Running ARI on Azure Runbook got error "The command cannot remove the job with the job ID 10 and the name ResourceJob_Compute because the job is not finished. To remove the job, first stop the job, or use the Force parameter" #317

@kd-jessada

Description

@kd-jessada

Runbook

Import-Module AzureResourceInventory

Import-Module ThreadJob

#Import-Module Microsoft.PowerShell.ThreadJob

Invoke-ARI -TenantID -Automation -StorageAccount "mystrageaccount" -StorageContainer "mystoragecontainer"

Runtime Environment PS 7.4

Az
Azure CLI
Az.Accounts
Az.Compute
Az.CostManagement
Az.OperationalInsights
Az.ResourceGraph
Az.Storage
AzureResourceInventory
ImportExcel
Microsoft.PowerShell.ThreadJob
ThreadJob

Results

Runbook completely ran with errors. Got both .xlsx and .xml (for drawio)
drawio shows all resources on all subscriptions but excel has only Overview, Subscriptions and Advisory sheet.
Have tried with only Microsoft.PowerShell.ThreadJob imported, only ThreadJob imported and both imported in runtime environment but still got the same ThreadJob errors. Please advise.

Errors

5/7/2025, 8:13:04 AM - Warning: TenantId 'xxxxxxxxx-yyyy-zzzzz-abc-ddddddddddd' contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext.
5/7/2025, 8:13:04 AM - Warning: To override which subscription Connect-AzAccount selects by default, use Update-AzConfig -DefaultSubscriptionForLogin 00000000-0000-0000-0000-000000000000. Go to https://go.microsoft.com/fwlink/?linkid=2200610 for more information.
5/7/2025, 8:13:06 AM - Output:
Name : Default
Subscription : aaaaaaaa-bbbb-cccc-ddd-eeeeeeeeeeee
Account : MSI@50342
Environment : AzureCloud
Tenant : xxxxxxxxx-yyyy-zzzzz-abc-ddddddddddd
TokenCache :
VersionProfile :
ExtendedProperties : {}

5/7/2025, 8:13:45 AM - Output: Extraction Phase Finished
5/7/2025, 8:13:45 AM - Output: Total Extraction Time: 00:00:00:36:918
5/7/2025, 8:13:45 AM - Output: Invoking Draw.Io main function.
5/7/2025, 8:13:45 AM - Output:
Id Name PSJobTypeName State HasMoreData Location Command


1 DiagramVariabl… ThreadJob NotStarted False PowerShell …

5/7/2025, 8:13:45 AM - Output: 2 Diagram_Subscr… ThreadJob NotStarted False PowerShell …

5/7/2025, 8:13:45 AM - Output: 3 Diagram_Organi… ThreadJob NotStarted False PowerShell …

5/7/2025, 8:13:46 AM - Output: 1 DiagramVariabl… ThreadJob Completed True PowerShell …

5/7/2025, 8:13:46 AM - Output: 4 Diagram_Networ… ThreadJob NotStarted False PowerShell …

5/7/2025, 8:14:18 AM - Output: 2 Diagram_Subscr… ThreadJob Completed True PowerShell …

5/7/2025, 8:14:18 AM - Output: 3 Diagram_Organi… ThreadJob Completed True PowerShell …

5/7/2025, 8:14:18 AM - Output: 4 Diagram_Networ… ThreadJob Completed True PowerShell …

5/7/2025, 8:14:18 AM - Output: [
[
[
"System.Xml.XmlElement"
]
]
]
5/7/2025, 8:14:19 AM - Output: [
[
[
"System.Xml.XmlElement"
]
],
[
[
"System.Xml.XmlElement"
]
]
]
5/7/2025, 8:14:19 AM - Output: Starting Advisory Job
5/7/2025, 8:14:19 AM - Output: Starting Subscription Job
5/7/2025, 8:14:19 AM - Output: 2025-05-07_01_14_19 - Processing Resources in Automation Mode
5/7/2025, 8:14:21 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 7 and the name ResourceJob_AI because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 8 and the name ResourceJob_Analytics because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 9 and the name ResourceJob_APIs because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 10 and the name ResourceJob_Compute because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 11 and the name ResourceJob_Container because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 12 and the name ResourceJob_Database because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 13 and the name ResourceJob_Hybrid because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 14 and the name ResourceJob_Integration because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 15 and the name ResourceJob_IoT because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 16 and the name ResourceJob_Management because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 17 and the name ResourceJob_Monitoring because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 18 and the name ResourceJob_Network_1 because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 19 and the name ResourceJob_Network_2 because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:22 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 20 and the name ResourceJob_Security because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:23 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 21 and the name ResourceJob_Storage because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:23 AM - Error: Remove-Job: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\2.ProcessingFunctions\Build-ARICacheFiles.ps1:43
Line |
43 | Remove-Job -Name $Job
| ~~~~~~~~~~~~~~~~~~~~~
| The command cannot remove the job with the job ID 22 and the name ResourceJob_Web because the job is not finished. To remove the job, first stop the job, or use the Force parameter. (Parameter 'Name')

5/7/2025, 8:14:26 AM - Output: Processing Phase Finished
5/7/2025, 8:14:26 AM - Output: Total Processing Time: 00:00:00:39:509
5/7/2025, 8:14:27 AM - Output: Starting to Build Excel Report.
5/7/2025, 8:22:37 AM - Warning: Could not find C:\AzureResourceInventory\ARI_Automation_Report_2025-05-07_01_13.xlsx
5/7/2025, 8:22:55 AM - Error: Close-ExcelPackage: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\3.ReportingFunctions\Start-ARIExcelExtraData.ps1:245
Line |
245 | Close-ExcelPackage $excel
| ~~~~~~
| Cannot bind argument to parameter 'ExcelPackage' because it is null.

5/7/2025, 8:23:26 AM - Error: OperationStopped: C:\usr\src\PSModules\AzureResourceInventory\modules\Private\3.ReportingFunctions\Start-ARIExtraReports.ps1:92
Line |
92 | … while (get-job -Name 'Advisory' | Where-Object { $_.State -eq 'R …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception of type 'System.OutOfMemoryException' was thrown.

5/7/2025, 8:23:27 AM - Error: Import-Module:
Line |
3 | import-module $($args[1])
| ~~~~~~~~
| Exception of type 'System.OutOfMemoryException' was thrown.

5/7/2025, 8:23:35 AM - Error: Import-Module:
Line |
3 | import-module $($args[2])
| ~~~~~~~~
| Exception of type 'System.OutOfMemoryException' was thrown.

5/7/2025, 8:23:43 AM - Warning: Failed adding PivotTable 'P3': Cannot index into a null array.
5/7/2025, 8:23:43 AM - Warning: Failed adding chart for pivotable 'P3': Cannot bind argument to parameter 'PivotTable' because it is null.
5/7/2025, 8:23:43 AM - Warning: Failed adding PivotTable 'P4': Cannot index into a null array.
5/7/2025, 8:23:43 AM - Warning: Failed adding chart for pivotable 'P4': Cannot bind argument to parameter 'PivotTable' because it is null.
5/7/2025, 8:23:43 AM - Warning: Failed adding PivotTable 'P5': Cannot index into a null array.
5/7/2025, 8:23:43 AM - Warning: Failed adding chart for pivotable 'P5': Cannot bind argument to parameter 'PivotTable' because it is null.
5/7/2025, 8:23:44 AM - Output: Report Building Finished
5/7/2025, 8:23:44 AM - Output: Total Processing Time: 00:00:09:17:827
5/7/2025, 8:23:46 AM - Output: Sending Excel file to Storage Account:
5/7/2025, 8:23:46 AM - Output: C:\AzureResourceInventory\ARI_Automation_Report_2025-05-07_01_13.xlsx
5/7/2025, 8:23:50 AM - Output: Sending Diagram file to Storage Account:
5/7/2025, 8:23:50 AM - Output: C:\AzureResourceInventory\ARI_Automation_Diagram_2025-05-07_01_13.xml

================================

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions