1 year ago

#280958

test-img

dontron

How to use invoke command to install .msi file on remote system which requires elevated permissions

I am trying to run an msiinstaller file on a remote system using the invoke-command. I have tried a couple of different methods but both have been unsuccessful to this point. They don't error out but they don't seem to run the install on the remote system either. At least as far as I can tell. Nothing in the event log, still on the old version of software I am trying to update.

I will post both methods here to see if either one of them is close and someone can get me over the top. thanks in advance. [I tend to get confused with how to properly use the invoke command so please cut me some slack if I am totally off base on these attempts.]

common for both: using get-credential to load up var $cred var targetHost is the remote system

first method:

$MsiInstallPath = "c:\Temp\MSI\file.msi"
$MsiArguments = " /i `"$MsiInstallPath`" /q SITE_TOKEN='adsfads' "
invoke-command -ComputerName $targetHost -Scriptblock { param($msi_args) Start-Process msciexec.exe -ArgumentList $msi_args } -ArgumentList $MsiArguments

second method:

$scriptblock = { Start-Process msiexec.exe -ArgumentList "/i $MsiInstallPath", "/q", "SITE_TOKEN='abcd'" }
invoke-command -ComputerName $targetHost -Credential $cred -ScriptBlock $scriptblock

Any insight or assistance would be most appreciated. Thanks D

powershell

invoke-command

0 Answers

Your Answer

Accepted video resources