Private/OSB-Upgrade.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function OSB-Upgrade-Module {
    [CmdletBinding()]
    PARAM ()
    try {
        Write-Warning "Uninstall-Module -Name OSBuilder -AllVersions -Force"
        Uninstall-Module -Name OSBuilder -AllVersions -Force
    }
    catch {}

    try {
        Write-Warning "Install-Module -Name OSBuilder -Force"
        Install-Module -Name OSBuilder -Scope CurrentUser -Force
    }
    catch {}

    try {
        Write-Warning "Import-Module -Name OSBuilder -Force"
        Import-Module -Name OSBuilder -Force
    }
    catch {}
}

function OSB-Upgrade-RemoveCatalogs {
    [CmdletBinding()]
    PARAM ()
    if (Test-Path "$CatalogLocal") {
        $CatalogsRemove = $(Get-Content $CatalogLocal | ConvertFrom-Json).CatalogsRemove
        foreach ($Catalog in $CatalogsRemove) {
            Get-ChildItem "$OSBuilderContent\Updates\*" -Include "$Catalog" -Recurse | foreach {
                Write-Warning "Removing $($_.FullName)"
                Remove-Item $_.FullName -Force | Out-Null
            }
        }
    }
}