Skip to content

Instantly share code, notes, and snippets.

@aclk
Created August 7, 2021 08:07
Show Gist options
  • Select an option

  • Save aclk/0633f97dd6aecf5936a9cc6ccec47ce4 to your computer and use it in GitHub Desktop.

Select an option

Save aclk/0633f97dd6aecf5936a9cc6ccec47ce4 to your computer and use it in GitHub Desktop.

Revisions

  1. aclk created this gist Aug 7, 2021.
    53 changes: 53 additions & 0 deletions install_chocolate.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    $creds = Get-Credential
    $username = $creds.GetNetworkCredential().UserName
    $password = $creds.GetNetworkCredential().Password
    $proxyServer = "https://local/proxy/server"

    $webProxy = New-Object System.Net.WebProxy($proxyServer,$true)
    $webclient = new-object System.Net.WebClient
    $creds = Get-Credential
    $webclient.Proxy=$webproxy
    $webclient.Proxy.Credentials = $creds

    $env:chocolateyProxyLocation = $proxyServer
    $env:chocolateyProxyUser = $username
    $env:chocolateyProxyPassword = $password

    $env:https_proxy = "https://${username}:${password}@${$proxyServer}"


    # Set directory for installation - Chocolatey does not lock
    # down the directory if not the default
    $InstallDir='$env:LOCALAPPDATA\chocoportable'
    $env:ChocolateyInstall="$InstallDir"

    # set proxy info in user environment
    [Environment]::SetEnvironmentVariable("chocolateyProxyLocation", $proxyServer, "User")
    [Environment]::SetEnvironmentVariable("chocolateyProxyUser", $username, "User")
    [Environment]::SetEnvironmentVariable("chocolateyProxyPassword", $password, "User")

    [Environment]::SetEnvironmentVariable("ChocolateyInstall", $InstallDir, "User")
    [Environment]::SetEnvironmentVariable("PATH", "%ChocolateyInstall%\bin;"+$env:Path, "User")


    # If your PowerShell Execution policy is restrictive, you may
    # not be able to get around that. Try setting your session to
    # Bypass.
    Set-ExecutionPolicy Bypass

    # All install options - offline, proxy, etc at
    # https://chocolatey.org/install
    iex ($webclient.DownloadString('https://chocolatey.org/install.ps1'))
    # PowerShell 3+?
    #iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex


    choco install git.commandline -y

    # pick an editor
    #choco install visualstudiocode.portable -y # not yet available
    #choco install nano -y
    #choco install vim-tux.portable

    # What else can I install without admin rights?
    # https://chocolatey.org/packages?q=id%3Aportable