首页 文章

如何在Chocolatey包安装脚本中指定端口?

提问于
浏览
1

我创建了一个PowerShell脚本,询问用户是否要安装Chocolatey然后安装一堆应用程序并移动一些文件 .

我在公司网络上使用它,遗憾的是,我们使用的代理设置带来了问题 . 当我执行Chocolatey脚本时,它表示存在错误,无法下载该软件包 . 最烦人的是错误描述是“没有更多数据可用” . 因此,在尝试运行脚本时,我在后台运行Wireshark,并被告知脚本正在尝试直接连接到一个盒子,它不应该在那里,这就是为什么它被拒绝了 .

有人告诉我解决这个问题,我需要强制脚本走出端口80.我不知道该怎么做,所以正在寻找一些如何实现这一目标的建议 .

我想它就像在某处添加_497543一样简单但是,我已经尝试过了,但没有运气 .

#-Setting HTTP/S Proxy's-#

write-host "Configuring local proxy settings"
cscript configs\SetProxy_underscore.vbs

function Install-NeededFor {
param(
   [string] $packageName = ''
  ,[bool] $defaultAnswer = $true
)

  if ($packageName -eq '') { return $false }

  $yes = '6'
  $no = '7'
  $msgBoxTimeout='-1'
  $defaultAnswerDisplay = 'Yes'
  $buttonType = 0x4;
  if (!$defaultAnswer) { $defaultAnswerDisplay = 'No'; $buttonType= 0x104; }

  $answer = $msgBoxTimeout
  try {
    $timeout = 10
    $question = "Do you need to install $($packageName)? Defaults to `'$defaultAnswerDisplay`' after $timeout seconds"
    $msgBox = New-Object -ComObject WScript.Shell
    $answer = $msgBox.Popup($question, $timeout, "Install $packageName", $buttonType)
  } catch {
  }

  if ($answer -eq $yes -or ($answer -eq $msgBoxTimeout -and $defaultAnswer -eq $true)) {
    write-host "Installing $packageName"
    return $true
  }

  write-host "Not installing $packageName"
  return $false
}

#-install chocolatey-#

if (Install-NeededFor 'chocolatey') {
  iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))
}

choco install dotnet4.5 -y
cinst nuget.commandline -y
cinst chefdk -y
cinst notepadplusplus -y
cinst vagrant -y
cinst vagrant-winrm-config -y
cinst virtualbox -version 4.3.12 -y
choco install virtualbox -version 4.3.12 -y
cinst atom -y
cinst putty -y
cinst winscp -y
cinst conemu -y
cinst launchy -y
cinst everything -y
choco install git.install -y -params '"/GitAndUnixToolsOnPath"'
choco install git-credential-winstore -y

vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-proxyconf
vagrant plugin install vagrant-omnibus

1 回答

相关问题