[英]PowerShell Install MSI with Property File
I looking to replace our old command files with PowerShell file to install msi on a number of servers with a view of automating installations remotely. 我希望用PowerShell文件替换旧的命令文件,以便在多个服务器上安装msi,以实现远程自动安装。
What I am trying to do, and this is how can you get PowerShell to install an msi where the installation relies on a details coming from a property file as one argument along with logging out the installation as a log file and setting a new user name and password? 我正在尝试执行的操作,这就是如何使PowerShell安装msi,其中安装依赖于来自属性文件的详细信息作为一个参数,同时将安装注销为日志文件并设置新的用户名。和密码?
Currently our old cmd file looks a bit like this: 当前,我们的旧cmd文件看起来像这样:
msiexec /I mymsi.msu /quiet /lv mymsi.log USERNAME=AName PASSWORD=APassword CONFIG="C:\\Some.properties.env" msiexec / I mymsi.msu / quiet / lv mymsi.log USERNAME = AName PASSWORD = APassword CONFIG =“ C:\\ Some.properties.env”
What I want to do is recreate this but in PowerShell, but I have not been able to find an example that works. 我想要做的是在PowerShell中重新创建它,但是我找不到能起作用的示例。
I'd suggest using Start-Process
and Splatting
to make it readable and functional: 我建议使用
Start-Process
和Splatting
使其可读性和功能性:
$startProcessParams = @{
'FilePath' = "$Env:SystemRoot\System32\MSIEXEC.exe"
'ArgumentList' = @(
'/i', 'mymsi.msu'
'/quiet'
'/lv', 'mymsi.log'
'USERNAME=AName', 'PASSWORD=APassword', 'CONFIG="C:\Some.properties.env"'
)
'WorkingDirectory' = $PSScriptRoot
'Wait' = $true
'PassThru' = $true
}
$process = Start-Process @startProcessParams
return $process.ExitCode
Be sure to set WorkingDirectory
to where your .msu
file is living. 确保将
WorkingDirectory
设置为您的.msu
文件所在的位置。
about_Splatting
Start-Process
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.