powershell - 使用 Powershell 远程安装 .msi

标签 powershell windows-installer windows-server-2008-r2 powershell-remoting

我已经使用该论坛上提供的代码让他遵循代码。

cls
$computername = Get-Content 'C:\Users\C201578-db\Documents\server.txt'
$sourcefile = "\\iceopsnas\LNT_SoftwareRep.grp\CORE\COTS\EMC\Avamar\Avamar_7.0\CR06794393\AvamarClient-windows-x86_64-7.0.102-47.msi"
#This section will install the software 
foreach ($computer in $computername) 
{
    $destinationFolder = "\\$computer\C$\Avamar"
    #This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
    if (!(Test-Path -path $destinationFolder))
    {
        New-Item $destinationFolder -Type Directory
    }
    Copy-Item -Path $sourcefile -Destination $destinationFolder
    Write-Host "Copied Successfully"
    Invoke-Command -ComputerName $computer -ScriptBlock { & cmd /c "msiexec.exe /i C:\Avamar\AvamarClient-windows-x86_64-7.0.102-47.msi" /qb ADVANCED_OPTIONS=1 CHANNEL=100}
    Write-Host "Installed Successfully"
}

我尝试了所有的排列和组合,但没有成功。尝试了发布此问题时收到的所有建议,但没有任何建议。复制过程成功,但未安装 .msi 文件。也许这个问题被标记为重复,但在这样做之前仍然建议进行一些编辑。

最佳答案

尝试将命令定义为脚本 block :

    $command =  "msiexec.exe /i C:\Avamar\AvamarClient-windows-x86_64-7.0.102-47.msi" 
    $scriptblock = [Scriptblock]::Create($command)
    Invoke-Command -ComputerName $computer -ScriptBlock $scriptblock

关于powershell - 使用 Powershell 远程安装 .msi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29911768/

相关文章:

wix - 在使用 wix 安装程序安装任何版本之前强制卸载

c# - 通过 msi 文件在 Windows Mobile 中部署 .Net Compact Framework 应用程序

windows-installer - 是否可以在InstallValidate之前安排RemoveExistingProducts自定义操作?

Powershell:压缩文件

powershell - 从AssemblyInfo.cs获取并替换AssemblyVersion

powershell - 在保留 Set-Location 开关的同时扩展 cd 功能

ssl - 为没有 FQDN 的远程桌面颁发 SSL 证书

java - 当有足够的可用 RAM 时,为什么 Java 垃圾收集器会启动?

linux - 两台 Linux 服务器之间的 PowerShell 远程执行

python - "try: input() except KeyboardInterrupt:"有解决方法吗