Initial
This commit is contained in:
46
functions/Invoke-BoxStarterRemoteUpgrade.ps1
Normal file
46
functions/Invoke-BoxStarterRemoteUpgrade.ps1
Normal 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
|
||||
# }
|
||||
}
|
||||
Reference in New Issue
Block a user