简体   繁体   English

如何在PowerShell中使用install-package cmdlet安装多个包?

[英]How to install multiple packages using install-package cmdlet in powershell?

I'm setting up a package installation solution for my school. 我正在为我的学校设置一个包安装解决方案。 All of your packages are .msi. 你的所有软件包都是.msi。 We are using powershell package manager to install everything. 我们使用PowerShell包管理器来安装所有东西。 I want to be able to push the packages one shot one after another remotely from a remote server. 我希望能够从远程服务器远程推送一个接一个的包。

When installing one package at a time providing the exact path of the msi, it works. 当一次安装一个包提供msi的确切路径时,它可以工作。 However, all my attempts to make a huge automated install failed as my code doesn't accept wildcars (the *). 但是,由于我的代码不接受野火(*),因此我尝试进行大规模自动安装失败。

Here is my code: 这是我的代码:

$Computers = Get-Content -Path "E:\servername\share\computer\test.txt"
$SharePath = "\\server.domain.ca\share\repo\MSI"
$Cred = Get-Credential $env:USERNAME


foreach ($Computer in $Computers)
    {
        $Computer
        Invoke-Command -ComputerName $Computer -Credential $Cred  -ScriptBlock {
        $null = New-PSDrive -Credential $using:Cred server -Root (Split-Path -Parent $using:SharePath) -PSProvider FileSystem
        Install-Package '\\servername\share\repo\MSI\*.msi'}
    }

The error I have is The specified name ****** should not contain any wildcard characters. 我遇到的错误是指定的名称******不应包含任何通配符。

I want to be able to install my packages in one go.... got any idea how to do it? 我希望能够一次性安装我的包....知道怎么做吗?

您可以使用Get-Item获取与通配符匹配的所有文件,并使用循环来安装每个包:

Get-Item '\\servername\share\repo\MSI\*.msi' | foreach { Install-Package $_ }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在正常的PowerShell会话中(不在Visual Studio中)运行Nuget PowerShell cmdlet Install-Package? - How can I run Nuget PowerShell cmdlet Install-Package in normal PowerShell session (not inside Visual Studio)? 如何使用 Install-Package 为 PowerShell 安装 MongoDB 驱动程序? - How do I install MongoDB driver for PowerShell using Install-Package? Nuget的Powershell安装包 - Powershell Install-Package from Nuget 使用Install-Package时跳过确认? - Skip confirmation while using Install-Package? Find-Package 有效,但 Install-Package 在 powershell 中使用 Chocolatey 仅显示 nuget 错误 - Find-Package works but Install-Package shows only nuget error using chocolatey in powershell 如何使用nuget.org的OneGet / install-package安装软件包 - How do I install a package using OneGet / install-package from nuget.org 错误:PowerShell 模块中的安装包验证码颁发者 - Error: Install-Package Authenticode issuer in PowerShell module 如何为OneGet安装软件包创建可执行软件包? - How can I create executable package for OneGet Install-Package? Powershell`install-package`工作正常,但`get-package`不显示已安装的软件包 - Powershell `install-package` works fine, but `get-package` doesn't show the package installed 如何通过Powershell运行win32-openssh? (与Chocolatey提供程序的安装包一起安装) - How do I run win32-openssh through the powershell? (installed with install-package from chocolatey provider)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM