New*_*per 16 powershell windows-installer
我是PowerShell的新手,对理解有些困难.
我想安装一个.MSI内部PowerShell脚本.
可以请解释我如何做到这一点或提供我初学者水平教程.
$wiObject = New-Object -ComObject WindowsInstaller.Installer
?????
Run Code Online (Sandbox Code Playgroud)
Adi*_*bar 16
为什么这么喜欢它?只需调用.msi文件:
& <path>\filename.msi
Run Code Online (Sandbox Code Playgroud)
要么
Start-Process <path>\filename.msi
Run Code Online (Sandbox Code Playgroud)
编辑:启动过程参数的完整列表
https://ss64.com/ps/start-process.html
小智 6
#Variables
$computername = Get-Content 'M:\Applications\Powershell\comp list\Test.txt'
$sourcefile = "\\server\Apps\LanSchool 7.7\Windows\Student.msi"
#This section will install the software
foreach ($computer in $computername)
{
$destinationFolder = "\\$computer\C$\download\LanSchool"
#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
Invoke-Command -ComputerName $computer -ScriptBlock { & cmd /c "msiexec.exe /i c:\download\LanSchool\Student.msi" /qn ADVANCED_OPTIONS=1 CHANNEL=100}
}
Run Code Online (Sandbox Code Playgroud)
我自己一直在寻找这个,并想出了zilch,但最后拼凑了这个工作剧本.它工作得很棒!我以为我希望其他人可以受益.它会提取计算机列表,将文件复制到本地计算机并运行它.:) 派对!
当尝试使用以下命令通过PowerShell静默安装MSI时:
Start-Process $webDeployInstallerFilePath -ArgumentList '/quiet' -Wait
Run Code Online (Sandbox Code Playgroud)
我收到错误:
指定的可执行文件不是此OS平台的有效应用程序。
我改为使用msiexec.exe此命令来执行MSI,它按预期方式工作:
$arguments = "/i `"$webDeployInstallerFilePath`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Run Code Online (Sandbox Code Playgroud)
希望其他人觉得这很有用。
您可以使用:
msiexec /i "c:\package.msi"
Run Code Online (Sandbox Code Playgroud)
您还可以添加更多可选参数。有常见的 msi 参数和特定于您的安装程序的参数。对于常用参数,只需调用msiexec
| 归档时间: |
|
| 查看次数: |
111099 次 |
| 最近记录: |