Skip to content

Commit 4727d2a

Browse files
Import offline OS catalog in Get-OSDCloudOperatingSystemsIndexMap.ps1
Fix bug in the previous version. Use UTF8 for tentative workaround.
1 parent 183dddf commit 4727d2a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexMap.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,19 @@ function Get-OSDCloudOperatingSystemsIndexMap {
2121
$OSArch = 'x64'
2222
)
2323

24-
$indexMapPath = "$(Get-OSDModulePath)\cache\archive-cloudoperatingindexmap\CloudOperatingIndexMap.json"
25-
$Results = Get-Content -Path $indexMapPath | ConvertFrom-Json
24+
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
25+
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingIndexMap.json" -File -Force -Recurse -ErrorAction Ignore
26+
}
27+
if ($OfflineCatalog) {
28+
foreach ($Item in $OfflineCatalog) {
29+
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
30+
$indexMapPath = (Get-Item -Path "$($Item.FullName)").FullName
31+
}
32+
} else {
33+
$indexMapPath = "$(Get-OSDCachePath)\archive-cloudoperatingindexmap\CloudOperatingIndexMap.json"
34+
}
35+
$Results = Get-Content -Path $indexMapPath -Encoding UTF8 | ConvertFrom-Json # as of OSD 25.6.10.1 encoding of the json is UTF8
2636
$Results = $Results | Where-Object { $_.Architecture -eq $OSArch }
2737

2838
return $Results
29-
}
39+
}

0 commit comments

Comments
 (0)