Shouldnt it be possible to install a msi file on a remote servers through powershell?
When i run my “code” locally the installation works but when i put the code in a script block and using invoke-command nothing happens…
Possible, yes. Straightforward, not necessarily. It depends entirely on what the MSI is trying to do - if it’s raising any kind of interactive UI, or trying to access any non-local resources, it’ll fail. A lot of MSIs also expect to have a user profile available to write to - e.g., directories, registry, etc. When you connect via Invoke-Command, you don’t spin up a profile, and so that can cause the MSI to fail also. Not much workaround except rewriting the MSI itself to not have those requirements.
I have now changed my “code” a little bit.
Now it works the way i want it except for one small issue… I have to be LOGGED IN on the servers!!!
If im not logged in to the servers my script copies the msi file to the temp folder as it should and then tries to start the install but fails.
(10837 Error MsiInstaller Application 2015-02-04 15:10:38)
If im logged on to the remote servers when i run my scripts from the mgmt server it works as planned. (The same account which runs the script from the mgmt server)
All my servers are windows2012r2.
foreach ($comp in $computers)
{
$destinationFolder = "\$comp\d$\temp" #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
}
This isn’t a PowerShell problem, no. The MSI is attempting to write to the local profile; when you’re not logged in on the server, there isn’t a profile for it to write to, and so it fails. There’s not much you can do about that except repackage the MSI to not need a local session. It’s probably trying to write icons to a Start menu folder or something.