Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

install msi using remoting?

$
0
0

I'm trying to install an msi using remoting. It works without  error when I run through each step in an interactive session using Enter-PSSesion, but fails when I try the same sequence using Invoke-Command. The general code is as follows

function Invoke-MsiInstall {

  Param ($msiFile, $servers)

Scriptblock = { 

    Param ($msiFile)

    $Args = "/i  C:\windows\temp\$msiFile /qn"

    Start-Process msiexec.exe $Args -wait 

}

New-PsSession $Servers 

Invoke-Command  -Session (Get-PsSession) -Scriptblock  $ScriptBlock -ArgumentList ($msiFile=$msiFile) -asJob 

}

 

Invoke-MsiInstall -msiFile foo.msi -servers  $serverlist

( the file foo.msi  is copied to each server first )

 

I'm confounded as to why this works interactively using Enter-PsSession but doesn't work using Invoke-Command.

 

Any help is most appreciated! 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles