This commit is contained in:
dfrancis-adm
2019-04-25 10:55:56 -04:00
commit 72a469c9b7
27 changed files with 1170 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
function Invoke-BoxStarterRemoteUpgrade {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string[]]$ComputerName,
[pscredential]$Credential,
[string[]]$AdditionalPackages,
[string[]]$ExcludedPackages,
[string]$ScriptPath,
[int]$JobTimeout
)
#Create dynamic upgrade list
Invoke-Command -ArgumentList $AdditionalPackages,$ExcludedPackages,$ScriptPath -ComputerName $ComputerName -ScriptBlock {
param (
$AdditionalPackages,
$ExcludedPackages,
$ScriptPath
)
if (Test-Path $ScriptPath) {
Remove-Item $ScriptPath -Force
}
$packages = [System.Collections.ArrayList]@(choco outdated -r --ignore-unfound --ignore-pinned | Foreach-Object {
($_.split("|"))[0]
})
foreach ($AddedPackage in $AdditionalPackages){
if ($packages -notcontains $AddedPackage){
$packages.Add($AddedPackage) | Out-Null
}
}
foreach ($ExcludedPackage in $ExcludedPackages){
if ($packages -contains $ExcludedPackage){
$packages.Remove($ExcludedPackage) | Out-Null
}
}
$Packages | ForEach-Object {
Add-Content $ScriptPath -Value "choco upgrade $_ -r -y --timeout=600"
}
}
#Upgrade computers with Boxstarter
Install-BoxstarterPackage -ComputerName $ComputerName -PackageName $ScriptPath
#Upgrade computers in parallel with Boxstarter
# $ComputerName | ForEach-Object {
# start-process -RedirectStandardOutput C:\scripts\powershell\$_.txt -FilePath powershell -ArgumentList "-windowstyle hidden Install-BoxstarterPackage -ComputerName $_ -PackageName $ScriptPath" -PassThru
# }
}