function Invoke-BoxStarterRemoteUpgrade {
    Uses Install-Boxstarterpackage to install packages remotely. In addition, provides ability to deploy new packages and exclude packages.
    Long description
    Here, we upgrade any out of date packages on winclient2, push out curl and git packages and exclude jre8 from updating.
    Each of these commands is created dynamically at runtime on a text file on the local machine called Boxstarterupgrade.txt
    Invoke-BoxStarterRemoteUpgrade -ComputerName winclient2 -Credential $DomainCred -AdditionalPackages curl,git -ExcludedPackages jre8 -ScriptPath C:\Windows\Temp\BoxstarterUpgrade.txt
     Here we use the -Parallel switch so that each remote machine is processed at the same time.
      Invoke-BoxStarterRemoteUpgrade -ComputerName winclient2 -Credential $DomainCred -AdditionalPackages curl,git -Parallel -ScriptPath C:\Windows\Temp\BoxstarterUpgrade.txt


    Invoke-Command -ArgumentList $AdditionalPackages,$ExcludedPackages,$ScriptPath -ComputerName $ComputerName -ScriptBlock {
        param (
        if (Test-Path $ScriptPath) {
            Remove-Item $ScriptPath -Force
            $packages = [System.Collections.ArrayList]@(choco outdated -r --ignore-unfound --ignore-pinned  | Foreach-Object {
        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"
    if (!$Parallel){
        Install-BoxstarterPackage -ComputerName $ComputerName -PackageName $ScriptPath -DelegateChocoSources
    else {
        $ComputerName | ForEach-Object {
              start-process -RedirectStandardOutput C:\Windows\Temp\$_.txt -FilePath powershell -ArgumentList "-windowstyle hidden Install-BoxstarterPackage -ComputerName $_ -PackageName $ScriptPath" -PassThru