Skip to content

Commit d408f92

Browse files
Import offline OS catalog in Get-OSDCloudOperatingSystemsIndexes.ps1
1 parent 4727d2a commit d408f92

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexes.ps1

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,30 @@ function Get-OSDCloudOperatingSystemsIndexes {
1919
)
2020

2121
if ($OSArch -eq 'x64') {
22-
$Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsIndexes.json" | ConvertFrom-Json
22+
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
23+
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystemsIndexes.json" -File -Force -Recurse -ErrorAction Ignore
24+
}
25+
if ($OfflineCatalog) {
26+
foreach ($Item in $OfflineCatalog) {
27+
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
28+
$Results = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop"
29+
}
30+
} else {
31+
$Results = Get-Content -Path "$(Get-OSDCachePath)\archive-cloudoperatingsystems\CloudOperatingSystemsIndexes.json" | ConvertFrom-Json
32+
}
2333
}
2434
elseif ($OSArch -eq "ARM64") {
25-
$Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsARM64Indexes.json" | ConvertFrom-Json
35+
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
36+
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystemsARM64Indexes.json" -File -Force -Recurse -ErrorAction Ignore
37+
}
38+
if ($OfflineCatalog) {
39+
foreach ($Item in $OfflineCatalog) {
40+
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
41+
$Results = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop"
42+
}
43+
} else {
44+
$Results = Get-Content -Path "$(Get-OSDCachePath)\archive-cloudoperatingsystems\CloudOperatingSystemsARM64Indexes.json" | ConvertFrom-Json
45+
}
2646
}
2747

2848
return $Results

0 commit comments

Comments
 (0)