Private/Install-TunerChocoPackages.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
function Install-TunerChocoPackages {
    [CmdletBinding(SupportsShouldProcess=$True)]
    param (
        [string] $Path = "",
        [string] $FileName = ""
    )
    if ($Path -eq "") {
        $path = Join-Path -Path $(Split-Path $PSScriptRoot) -ChildPath "Assets"
    }
    Write-Verbose "config file path: $path"
    try {
        $configfile = (Join-Path $path -ChildPath "$Configuration.txt")
        Write-Verbose "searching for config file: $configfile"
        if (Test-Path $configfile) {
            $pkglist = Get-Content -Path $configfile
            Write-Host "installing $($pkglist.Count) packages..." -ForegroundColor Magenta
            Invoke-TunerChocoPackages -PackageName $pkglist
        }
        else {
            Write-Warning "config file could not be found: $ConfigFile"
        }
    }
    catch {
        Write-Error "$($Error[0].Exception.Message)"
    }
}