Chocolatey无法找到窗户功能

时间:2016-06-07 22:31:38

标签: powershell octopus-deploy chocolatey

我使用Octopus deploy在目标计算机上运行PowerShell脚本,尝试安装IIS-WebServerRole。我使用下面的脚本并传递必要的参数。记录的内容让人相信呼叫正确,但它只是响应:

Chocolatey软件包存储库...

安装软件包17:11:48Info Installing the following packages: 17:11:48Info IIS-WebServerRole 17:11:48Info By installing you accept licenses for the packages. 17:11:48Info IIS-WebServerRole not installed. The package was not found with the source(s) listed. 17:11:48Info If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not. 17:11:48Info Version: "" 17:11:48Info Source(s): "windowsFeatures"
$chocolateyBin = [Environment]::GetEnvironmentVariable("ChocolateyInstall", "Machine") + "\bin"
if(-not (Test-Path $chocolateyBin)) {
    Write-Output "Environment variable 'ChocolateyInstall' was not found in the system variables. Attempting to find it in the user variables..."
    $chocolateyBin = [Environment]::GetEnvironmentVariable("ChocolateyInstall", "User") + "\bin"
}

$cinst = "$chocolateyBin\cinst.exe"
$choco = "$chocolateyBin\choco.exe"

if (-not (Test-Path $cinst) -or -not (Test-Path $choco)) {
    throw "Chocolatey was not found at $chocolateyBin."
}

if (-not $ChocolateyPackageId) {
    throw "Please specify the ID of an application package to install."
}

$chocoVersion = & $choco --version
Write-Output "Running Chocolatey version $chocoVersion"

$chocoArgs = @()
if([System.Version]::Parse($chocoVersion) -ge [System.Version]::Parse("0.9.8.33")) {
    Write-Output "Adding --confirm to arguments passed to Chocolatey"
    $chocoArgs += @("-y", "")
}

if($ChocolateyPackageSource) {
    Write-Output "Adding --source to arguments passed to Chocolatey"
    $chocoArgs += @("-source", $ChocolateyPackageSource)
}

if (-not $ChocolateyPackageVersion) {
    Write-Output "Installing package $ChocolateyPackageId from the Chocolatey package repository..."
    & $cinst $ChocolateyPackageId $($chocoArgs)
} else {
    Write-Output "Installing package $ChocolateyPackageId version $ChocolateyPackageVersion from the Chocolatey package repository..."
    & $cinst $ChocolateyPackageId -version $ChocolateyPackageVersion $($chocoArgs)
}

代码:

{{1}}

基于我能找到的最新的Chocolatey文档,这应该可行。任何想法为什么它不会?我应该提到这是在Azure Windows 2012 R2 VM上。

1 个答案:

答案 0 :(得分:2)

我能够通过碰到巧克力的预发布版本来实现这一目标。 9.10.x-beta ......

我应该注意,只是做一个-pre还不足以让它安装软件包...出于某种原因,我还必须强制使用软件包来获得更新。不确定这是否符合设计要求。