Skip to content

Commit

Permalink
Function edit
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiaschulz committed Dec 15, 2023
1 parent 0599519 commit 8813de6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
20 changes: 18 additions & 2 deletions pwsh/AzGovVizParallel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12461,7 +12461,15 @@ function processStorageAccountAnalysis {
}
else {
try {
$xmlSaProperties = [xml]([string]$saProperties -replace $saProperties.Substring(0, 3))
# ? https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/218#issuecomment-1854516882
if ($saProperties.gettype().Name -eq 'Byte[]') {
$byteArray = [byte[]]$saProperties
$saProperties = [System.Text.Encoding]::UTF8.GetString($byteArray)
}

# $xmlSaProperties = [xml]([string]$saProperties -replace $saProperties.Substring(0, 3)) # Leading character:  (PS version <= 7.3.9)
# $xmlSaProperties = [xml]([string]$saProperties -replace $saProperties.Substring(0, 1)) # Leading character:  or U+feff (PS version >= 7.4.0)
$xmlSaProperties = [xml]($saProperties -replace '^.*?<', '<') # Universal fix for all PS versions
if ($xmlSaProperties.StorageServiceProperties.StaticWebsite) {
if ($xmlSaProperties.StorageServiceProperties.StaticWebsite.Enabled -eq $true) {
$staticWebsitesState = $true
Expand Down Expand Up @@ -12494,7 +12502,15 @@ function processStorageAccountAnalysis {
}

if ($listContainersSuccess -eq $true) {
$xmlListContainers = [xml]([string]$listContainers -replace $listContainers.Substring(0, 3))
# ? https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/218#issuecomment-1854516882
if ($listContainers.gettype().Name -eq 'Byte[]') {
$byteArray = [byte[]]$listContainers
$listContainers = [System.Text.Encoding]::UTF8.GetString($byteArray)
}

# $xmlListContainers = [xml]([string]$listContainers -replace $listContainers.Substring(0, 3)) # Leading character:  (PS version <= 7.3.9)
# $xmlListContainers = [xml]([string]$listContainers -replace $listContainers.Substring(0, 1)) # Leading character:  or U+feff (PS version >= 7.4.0)
$xmlListContainers = [xml]($listContainers -replace '^.*?<', '<') # Universal fix for all PS versions
$containersCount = $xmlListContainers.EnumerationResults.Containers.Container.Count

foreach ($container in $xmlListContainers.EnumerationResults.Containers.Container) {
Expand Down
20 changes: 18 additions & 2 deletions pwsh/dev/functions/processStorageAccountAnalysis.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ function processStorageAccountAnalysis {
}
else {
try {
$xmlSaProperties = [xml]([string]$saProperties -replace $saProperties.Substring(0, 3))
# ? https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/218#issuecomment-1854516882
if ($saProperties.gettype().Name -eq 'Byte[]') {
$byteArray = [byte[]]$saProperties
$saProperties = [System.Text.Encoding]::UTF8.GetString($byteArray)
}

# $xmlSaProperties = [xml]([string]$saProperties -replace $saProperties.Substring(0, 3)) # Leading character:  (PS version <= 7.3.9)
# $xmlSaProperties = [xml]([string]$saProperties -replace $saProperties.Substring(0, 1)) # Leading character:  or U+feff (PS version >= 7.4.0)
$xmlSaProperties = [xml]($saProperties -replace '^.*?<', '<') # Universal fix for all PS versions
if ($xmlSaProperties.StorageServiceProperties.StaticWebsite) {
if ($xmlSaProperties.StorageServiceProperties.StaticWebsite.Enabled -eq $true) {
$staticWebsitesState = $true
Expand Down Expand Up @@ -92,7 +100,15 @@ function processStorageAccountAnalysis {
}

if ($listContainersSuccess -eq $true) {
$xmlListContainers = [xml]([string]$listContainers -replace $listContainers.Substring(0, 3))
# ? https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/218#issuecomment-1854516882
if ($listContainers.gettype().Name -eq 'Byte[]') {
$byteArray = [byte[]]$listContainers
$listContainers = [System.Text.Encoding]::UTF8.GetString($byteArray)
}

# $xmlListContainers = [xml]([string]$listContainers -replace $listContainers.Substring(0, 3)) # Leading character:  (PS version <= 7.3.9)
# $xmlListContainers = [xml]([string]$listContainers -replace $listContainers.Substring(0, 1)) # Leading character:  or U+feff (PS version >= 7.4.0)
$xmlListContainers = [xml]($listContainers -replace '^.*?<', '<') # Universal fix for all PS versions
$containersCount = $xmlListContainers.EnumerationResults.Containers.Container.Count

foreach ($container in $xmlListContainers.EnumerationResults.Containers.Container) {
Expand Down

0 comments on commit 8813de6

Please sign in to comment.