Powershell 巧克力罐头';找不到windows功能
我正在使用Octopus deploy在目标计算机上运行PowerShell脚本,试图安装Powershell 巧克力罐头';找不到windows功能,powershell,octopus-deploy,chocolatey,Powershell,Octopus Deploy,Chocolatey,我正在使用Octopus deploy在目标计算机上运行PowerShell脚本,试图安装IIS。我正在使用下面的脚本并传入必要的参数。记录的内容使人相信呼叫正确,但它只会以以下方式响应: 正在从chocolate程序包存储库安装程序包IIS WebServerRole 17:11:48Info Installing the following packages: 17:11:48Info IIS-WebServerRole 17:11:48Info By installing you acce
IIS
。我正在使用下面的脚本并传入必要的参数。记录的内容使人相信呼叫正确,但它只会以以下方式响应:
正在从chocolate
程序包存储库安装程序包IIS WebServerRole
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)
}
根据我能找到的最新巧克力文档,这应该是可行的。你知道为什么不会吗?我应该提到的是,这是在Azure Windows 2012 R2虚拟机上实现的。我通过升级到Chocolate的预发布版本,实现了这一点。9.10.x-beta
我应该注意到,仅仅做一个-pre不足以让它安装软件包……出于某种原因,我还不得不强迫软件包获得chocolate来更新自己。不确定这是否是出于设计。你不能在运行触手的用户的机器上手动运行powershell脚本吗?@AlexM-是的,即使我以管理员身份登录机器,我也会收到完全相同的消息。windows功能命令似乎不起作用。我甚至试过一些旧版本的电话,但也不起作用。我不太会吃巧克力,所以我想也许我做错了什么。当然不是故意的。如果你有它不工作的任何日志,我想看看。旁注,
choco升级巧克力-pre
,而不是choco安装巧克力-pre
/cinst巧克力-pre
。后两个命令将需要--force
,因为install是关于获得一些东西的安装,升级将从此开始。嗯。如果是其他原因,请告诉我。我确实确认我正在进行升级…不确定为什么需要强制,如果我再次这样做,我将发送一些日志。酷-请记住日志是以调试/详细格式获取的。所以当你想看的时候,这很有帮助。