support for uninstall, groups, host-packages and all packages, skip installed packages, upgade all at the end
This commit is contained in:
parent
5744413362
commit
154acce96c
@ -1,9 +1,58 @@
|
||||
$config = Get-Content 'config.ini' | ConvertFrom-StringData
|
||||
$hostname = $env:COMPUTERNAME
|
||||
Get-Content -Path .\packages_all.txt | ForEach-Object {
|
||||
choco.exe install -y $_
|
||||
$packages = @{}
|
||||
# list packages for all hosts
|
||||
Get-Content -Path "$($config.basePath)/packages_all.txt" | ForEach-Object {
|
||||
$packages[$_] = $_
|
||||
}
|
||||
|
||||
Get-Content -Path .\packages_$hostname.txt | ForEach-Object {
|
||||
choco.exe install -y $_
|
||||
# Check groups of host and list packages
|
||||
$groups = @{}
|
||||
Get-Content -Path "$($config.basePath)/groups_$($hostname).txt" | ForEach-Object {
|
||||
$groups[$_] = $_
|
||||
}
|
||||
choco upgrade all -y
|
||||
foreach ($group in $groups.keys) {
|
||||
Get-Content -Path "$($config.basePath)/packages_$($groups[$group]).txt" | ForEach-Object {
|
||||
$packages[$_] = $_
|
||||
}
|
||||
}
|
||||
|
||||
# Packages only for this host
|
||||
if (Test-Path -Path "$($config.basePath)/packages_$($hostname).txt") {
|
||||
Get-Content -Path "$($config.basePath)/packages_$($hostname).txt" | ForEach-Object {
|
||||
$packages[$_] = $_
|
||||
}
|
||||
}
|
||||
|
||||
# Pakete in der uninstall.txt sollen nicht installiert werden
|
||||
$uninstall = @{}
|
||||
Get-Content -Path "$($config.basePath)/uninstall.txt" | ForEach-Object {
|
||||
if($packages.ContainsKey($_)) {
|
||||
$uninstall[$_] = $_
|
||||
$packages.Remove($_)
|
||||
}
|
||||
}
|
||||
|
||||
# List installed packages
|
||||
$installed = @{}
|
||||
$installedStrings = @(choco list --no-progress)
|
||||
for ($i = 8; $i -lt $($installedStrings.Length -1 ); $i++) {
|
||||
$packagename = $installedStrings[$i].Split(" ")[0]
|
||||
$installed[$packagename] = $packagename
|
||||
}
|
||||
|
||||
# Install packages not in installed package list
|
||||
foreach ($package in $packages.keys) {
|
||||
if ( $installed.ContainsKey($package) -eq 1 ) {
|
||||
continue
|
||||
}
|
||||
choco install -y $package
|
||||
}
|
||||
|
||||
#Pakete in der uninstall deinstallieren
|
||||
foreach ($package in $uninstall.keys) {
|
||||
choco uninstall -y $package
|
||||
}
|
||||
|
||||
# Upgrade all installed packages
|
||||
#choco upgrade all -y
|
||||
|
Loading…
Reference in New Issue
Block a user