Skip to content

Commit bfe2c9b

Browse files
Import offline OS catalog in Get-OSDCloudOperatingSystems.ps1
1 parent 806028c commit bfe2c9b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Public/OSDCloudTS/Get-OSDCloudOperatingSystems.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ function Get-OSDCloudOperatingSystems {
1616
[System.String]
1717
$OSArch = 'x64'
1818
)
19-
$FullResults = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystems.json" | ConvertFrom-Json
20-
if ($OSArch -eq 'x64'){
21-
$Results = $FullResults | Where-Object {$_.Architecture -eq "x64"}
19+
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
20+
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystems.json" -File -Force -Recurse -ErrorAction Ignore
2221
}
23-
elseif ($OSArch -eq "arm64"){
24-
$Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsARM64.json" | ConvertFrom-Json
22+
if ($OfflineCatalog) {
23+
foreach ($Item in $OfflineCatalog) {
24+
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
25+
$FullResults = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop"
26+
}
27+
$Results = $FullResults | Where-Object {$_.Architecture -eq $OSArch}
28+
} else {
29+
$FullResults = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystems.json" | ConvertFrom-Json
30+
$Results = $FullResults | Where-Object {$_.Architecture -eq $OSArch}
2531
}
2632
$Results
2733
}

0 commit comments

Comments
 (0)