microsoft / ARI

Azure Resource Inventory - It's a Powerful tool to create EXCEL inventory from Azure Resources with low effort
MIT License
1.1k stars 394 forks source link

Visio File is not created - Tried in Windows 10 and in 2016 Server #51

Closed aayooshmoitro closed 2 years ago

aayooshmoitro commented 2 years ago

Hi, First of all, thank you for writing such a wonderful script. I was trying to get the diagram created but it never creates the file at the mentioned location. I have tried PowerShell and ISE mode as well but it doesn't work. VISIO is also installed with the correct License as well.

Please let me know if I am doing anything wrong. Thanks. image

ClaudioMerola commented 2 years ago

Hello,

Sorry for the delay.

What version of the script are you using?

I'm asking because that picture you posted only shows the Visio file, and the newer versions of the script also creates a Draw.io file.

Thanks

aayooshmoitro commented 2 years ago

Hi, Thank you for your response. I am using version: [2.1.10] in server 2016.

Also, I have noticed that if I use the same script on my windows 10 laptop (latest build) it does not even create the the excel sheet. But I am lucky that it created the Excel but the VSDS/Draw.IO

FYI: If I run this script from POWERSHELL ISE, it saves the excel on the mentioned location (default one) but if I run it from PowerShell only, it creates the file on C:\ root with file name: Report.(.xlsx). So I am little confused how to run this script properly and get the desired outcome. Thanks.

ClaudioMerola commented 2 years ago

Hi,

Is possible the server 2016 does not have some default libraries by default, like "System.XMl.XmlTextWriter", and that's why the script is not able to create the XML file.

In the Windows 10, what's the version of the resource graph extension? I believe it might be using the older version. Can you try to upgrade all the az cli extensions and verify if the ImportExcel module is installed?

If after that, you still have errors, can you run the script with -Debug parameter and paste the content here?

Thanks

aayooshmoitro commented 2 years ago

Hi, I did upgrade the AZ CLI and made sure Resource Graph is latest on Windows 10 machine and it still didnt create any file. Here is the debug info. I am seeing below error which points to dependent script/objects:

Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extras\Subscriptio ns.ps1'." New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extra s\Support.json'."

Below is the full snippet: Sorry for the poor formatting.

DEBUG: Looking for the following file: C:\scripts\Azure\Extras\Support.json New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extra s\Support.json'." At C:\scripts\Azure\AzureInventory.ps1:607 char:33 + ... $ModuSeq0 = New-Object System.IO.StreamReader($PSScriptRoot + '\Extra ... + ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:614 char:13 + $ModuSeq = $ModuSeq0.ReadToEnd() + ~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:615 char:13 + $ModuSeq0.Dispose() + ~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null. At C:\scripts\Azure\AzureInventory.ps1:618 char:35 + $Unsupported = $ModuSeq | ConvertFrom-Json + ~~~~ + CategoryInfo : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFrom JsonCommand DEBUG: Checking if Diagram Job Should be Run. DEBUG: Starting Diagram Processing Job. DEBUG: Checking If Should Run Security Center Job. DEBUG: Checking If Should Run Advisory Job. DEBUG: Starting Advisory Processing Job. DEBUG: Starting Subscriptions job. DEBUG: Starting Compute Processing Job. DEBUG: Starting Networking Processing Job. DEBUG: Starting Infrastructure Processing Job. DEBUG: Starting Database Processing Job. DEBUG: Starting Jobs Collector. DEBUG: Current Status of Job:Diagram. is: Completed DEBUG: Current Status of Job:Advisory. is: Completed DEBUG: Current Status of Job:Subscriptions. is: Completed DEBUG: Current Status of Job:Compute. is: Running DEBUG: Current Status of Job:Networking. is: Running DEBUG: Current Status of Job:Infrastructure. is: Running DEBUG: Current Status of Job:Database. is: Running DEBUG: Jobs Still Running: Compute Networking Infrastructure Database DEBUG: Jobs Compleated. Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extras\Subscriptio ns.ps1'." + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand + PSComputerName : localhost You cannot call a method on a null-valued expression. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull + PSComputerName : localhost You cannot call a method on a null-valued expression. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull + PSComputerName : localhost Cannot find path 'C:\scripts\Azure\Modules\Compute\' because it does not exist. + CategoryInfo : ObjectNotFound: (C:\scripts\Azure\Modules\Compute\:String) [Get-ChildItem], ItemNotFound Exception + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand + PSComputerName : localhost DEBUG: Compute Job Returned: 0 Resource Types. Cannot find path 'C:\scripts\Azure\Modules\Networking\' because it does not exist. + CategoryInfo : ObjectNotFound: (C:\scripts\Azure\Modules\Networking\:String) [Get-ChildItem], ItemNotFo undException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand + PSComputerName : localhost DEBUG: Networking Job Returned: 0 Resource Types. Cannot find path 'C:\scripts\Azure\Modules\Infrastructure\' because it does not exist. + CategoryInfo : ObjectNotFound: (C:\scripts\Azure\Modules\Infrastructure\:String) [Get-ChildItem], ItemN otFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand + PSComputerName : localhost DEBUG: Infrastructure Job Returned: 0 Resource Types. Cannot find path 'C:\scripts\Azure\Modules\Data\' because it does not exist. + CategoryInfo : ObjectNotFound: (C:\scripts\Azure\Modules\Data\:String) [Get-ChildItem], ItemNotFoundExc eption + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand + PSComputerName : localhost DEBUG: Database Job Returned: 0 Resource Types. DEBUG: Starting Reporting Phase. DEBUG: Running Offline, Gathering List Of Modules. Get-ChildItem : Cannot find path 'C:\scripts\Azure\Modules\' because it does not exist. At C:\scripts\Azure\AzureInventory.ps1:1172 char:32 + ... $Modules = Get-ChildItem -Path ($PSScriptRoot + '\Modules*.ps1') -R ... + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\scripts\Azure\Modules\:String) [Get-ChildItem], ItemNotFoundExceptio n + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand DEBUG: Modules Found: 0 DEBUG: Resource Reporting Phase Done. DEBUG: Checking if Should Generate Security Center Sheet. DEBUG: Checking if Should Generate Advisory Sheet. DEBUG: Generating Advisor Sheet. Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extras\Advisory.ps 1'." + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand + PSComputerName : localhost You cannot call a method on a null-valued expression. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull + PSComputerName : localhost You cannot call a method on a null-valued expression. + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull + PSComputerName : localhost DEBUG: Looking for the following file: C:\scripts\Azure\Extras\Advisory.ps1 New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extra s\Advisory.ps1'." At C:\scripts\Azure\AzureInventory.ps1:1338 char:37 + ... $ModuSeq0 = New-Object System.IO.StreamReader($PSScriptRoot + '\Extra ... + ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:1345 char:17 + $ModuSeq = $ModuSeq0.ReadToEnd() + ~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:1346 char:17 + $ModuSeq0.Dispose() + ~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull DEBUG: Generating Subscription sheet for: Subscriptions. DEBUG: Looking for the following file: C:\scripts\Azure\Extras\Subscriptions.ps1 New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extra s\Subscriptions.ps1'." At C:\scripts\Azure\AzureInventory.ps1:1376 char:33 + ... $ModuSeq0 = New-Object System.IO.StreamReader($PSScriptRoot + '\Extra ... + ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:1383 char:13

You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:1384 char:13

DEBUG: Generating Overview sheet (Charts). DEBUG: Looking for the following file: C:\scripts\Azure\Extras\Charts.ps1 New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find a part of the path 'C:\scripts\Azure\Extra s\Charts.ps1'." At C:\scripts\Azure\AzureInventory.ps1:1415 char:33

You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:1422 char:13

You cannot call a method on a null-valued expression. At C:\scripts\Azure\AzureInventory.ps1:1423 char:13

DEBUG: Finished Charts Phase. Report Complete. Total Runtime was: ,55 Minutes Total Resources: 262 Total Advisories: 211

Excel file saved at: Report.xlsx

Visio file saved at: C:\Export\AzureResourceInventory\AzureDiagramInventory_2022-02-18_15_46.vsdx

ClaudioMerola commented 2 years ago

By the errors it appears the script is missing the modules, have you downloaded all the modules files?

An easier test is to run the script using the "-Online" parameters, then it will search for the modules in the repository.

Thanks

aayooshmoitro commented 2 years ago

Hi,

-online Parameter did the trick. :) It created all the 3 files. Thank you soo much.

PS: do let us know if you have built other report/inventory scripts for Azure/Hyper-v/SCVMM so that we can leverage the same. Thanks a ton.

ClaudioMerola commented 2 years ago

Hello,

Glad it worked.

We are working in a new version of the Azure Cost Inventory tool, But we have no date for release yet.

Regarding On Premises, the closest of what you asked is a tool I created long time ago for Active Directory Inventory (https://github.com/ClaudioMerola/ADxRay). See if it helps.

Thanks