【问题标题】:MSIExec via Powershell InstallMSIExec 通过 Powershell 安装
【发布时间】:2019-03-07 17:11:06
【问题描述】:

从目录中查找 MSI 文件列表并远程或本地安装在给定的 PC 上。我希望能够运行一个脚本,该脚本将在给定目录中 1 个 1 个安装 8 个单独的 MSI 文件。我找到了这个脚本并认为它可以工作,但我觉得它好像缺少什么对吗?

foreach($_msiFiles in 
($_msiFiles = Get-ChildItem $_Source -Recurse | Where{$_.Extension -eq ".msi"} |
 Where-Object {!($_.psiscontainter)} | Select-Object -ExpandProperty FullName)) 
{
    msiexec /i $_msiFiles /passive
} 

【问题讨论】:

标签: powershell windows-installer


【解决方案1】:

这将帮助您了解这里发生了什么。我会这样写:

声明源目录:

$source = “\\path\to\source\folder”

将每个子 .msi 对象放入一个数组中:

$msiFiles = Get-Childitem $source -File -recurse | Where-Object {$_.Extension -eq “.msi”}

迭代数组以运行每个 .msi:

Foreach ($msi in $msiFiles) {

Msiexec /I “$($msi.FullName)” /passive

}

这当然只是对你在做什么的解释。它不包括任何错误处理、检查返回码或远程命令语法等。

【讨论】:

    猜你喜欢
    • 2022-11-24
    • 1970-01-01
    • 2016-03-11
    • 2014-02-16
    • 2013-05-15
    • 2014-03-12
    • 2017-10-17
    • 1970-01-01
    相关资源
    最近更新 更多