Install .msi remotely using Powershell
23,543
Solution 1
As a workaround (the lack of details doesnt help to daignose the problem), you could use the third party tool psexec.exe to run the installer on the remote host.
Try to replace your invoke-command with
psexec.exe \\$computer -s -u Adminuser -p AdminPassword msiexec /i C:\Avamar\AvamarClient-windows-x86_64-7.0.102-47.msi /qb ADVANCED_OPTIONS=1 CHANNEL=100
Solution 2
try defining your command as a script block instead:
$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
Author by
user2068804
Updated on August 17, 2020Comments
-
user2068804 over 3 years
I have made he following code using the code present on this forum.
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" }
I tried all permutations and combinations but no luck. Tried all the suggestions that I got while posting this question but nothing. The copy procedure is successful but the .msi file is not getting installed. Maybe this question gets marked duplicate but still suggest some edits before doing that.
-
user2068804 almost 9 yearsCould you please modify the above script and tell me if it is possible to modify the above code for installing an .exe file. Actually i'm trying to patch SQL remotely using powershell. Kindly give ur suggestion