From 593469dabffc797863d59e7197bfaf71033efe64 Mon Sep 17 00:00:00 2001 From: Quintin de Kok Date: Tue, 6 Dec 2022 15:17:14 +0200 Subject: [PATCH 1/3] fix: compatibility with WSL and Powershell Unix for draw.io diagram --- AzureResourceInventory.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AzureResourceInventory.ps1 b/AzureResourceInventory.ps1 index e11db55..1078f43 100644 --- a/AzureResourceInventory.ps1 +++ b/AzureResourceInventory.ps1 @@ -759,7 +759,7 @@ param ($TenantID, $ModuSeq = (New-Object System.Net.WebClient).DownloadString($($args[7]) + '/Extras/DrawIODiagram.ps1') } Else { - $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '\Extras\DrawIODiagram.ps1') + $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '/Extras/DrawIODiagram.ps1') $ModuSeq = $ModuSeq0.ReadToEnd() $ModuSeq0.Dispose() } @@ -1417,7 +1417,7 @@ Write-Host ('Excel file saved at: ') -NoNewline write-host $File -ForegroundColor Cyan Write-Host '' -if($Global:PlatOS -eq 'PowerShell Desktop' -and $Diagram.IsPresent) { +if(($Global:PlatOS -eq 'PowerShell Desktop' -or $Global:PlatOS -eq 'PowerShell Unix') -and $Diagram.IsPresent) { Write-Host ('Draw.io Diagram file saved at: ') -NoNewline write-host $DDFile -ForegroundColor Cyan Write-Host '' From ca0dc7d71e97067fc650a379560709d62763afb5 Mon Sep 17 00:00:00 2001 From: Claudio Merola <108147804+Claudio-Merola@users.noreply.github.com> Date: Wed, 7 Dec 2022 16:18:33 -0300 Subject: [PATCH 2/3] Update AzureResourceInventory.ps1 Hello, We need to add this if, or it might fail when running on regular Windows. --- AzureResourceInventory.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/AzureResourceInventory.ps1 b/AzureResourceInventory.ps1 index 1078f43..bf2c863 100644 --- a/AzureResourceInventory.ps1 +++ b/AzureResourceInventory.ps1 @@ -759,6 +759,14 @@ param ($TenantID, $ModuSeq = (New-Object System.Net.WebClient).DownloadString($($args[7]) + '/Extras/DrawIODiagram.ps1') } Else { + if($($args[0]) -like '*\*') + { + $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '\Extras\DrawIODiagram.ps1') + } + else + { + $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '/Extras/DrawIODiagram.ps1') + } $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '/Extras/DrawIODiagram.ps1') $ModuSeq = $ModuSeq0.ReadToEnd() $ModuSeq0.Dispose() @@ -1429,4 +1437,4 @@ if ($Diagram.IsPresent -and $Global:VisioCheck) { write-host $DFile -ForegroundColor Cyan Write-Host '' } -#> \ No newline at end of file +#> From b3447dbb88b85cebf5276ea02b04a942a25245ad Mon Sep 17 00:00:00 2001 From: Quintin de Kok Date: Thu, 8 Dec 2022 11:53:34 +0200 Subject: [PATCH 3/3] fix: added required validation to ensure cross compatibility as per comment https://github.com/microsoft/ARI/pull/91#pullrequestreview-1208986528 --- AzureResourceInventory.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AzureResourceInventory.ps1 b/AzureResourceInventory.ps1 index 1078f43..626215f 100644 --- a/AzureResourceInventory.ps1 +++ b/AzureResourceInventory.ps1 @@ -759,7 +759,14 @@ param ($TenantID, $ModuSeq = (New-Object System.Net.WebClient).DownloadString($($args[7]) + '/Extras/DrawIODiagram.ps1') } Else { - $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '/Extras/DrawIODiagram.ps1') + if($($args[0]) -like '*\*') + { + $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '\Extras\DrawIODiagram.ps1') + } + else + { + $ModuSeq0 = New-Object System.IO.StreamReader($($args[0]) + '/Extras/DrawIODiagram.ps1') + } $ModuSeq = $ModuSeq0.ReadToEnd() $ModuSeq0.Dispose() }