I'm trying to do a script in powershell that install msi files on remote machines in the same domain. When i use Invoke-Command to run simple cmdlets on remote machine everything works fine, but when i try to invoke msiexec i've got this error from msi log
MSI (c) (50:C4) [10:50:30:962]: Failed to connect to server. Error: 0x80070005
function in InstallFunction.ps1 file
function ManageMsi {
Param (
[Parameter(Mandatory=$true)]
[string] $msiFile,
[Parameter(Mandatory=$true)]
[MsiOperation] $operation,
[string] $TARGETVDIR,
[string] $TARGETAPPPOOL = "DefaultAppPoll" ,
[string] $logPath = $msiFile + ".txt"
)
begin {}
process {
try {
if($operation -eq [MsiOperation]::Install)
{
Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" `
-ArgumentList "/i `"$msifile`" /qn /L* `"$logPath`"" -Wait
}
if($operation -eq [MsiOperation]::Uninstall)
{
Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" `
-ArgumentList "/x `"$msifile`" /qn /L* `"$logPath`"" -Wait
}
if($operation -eq [MsiOperation]::InstallService)
{
Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" `
-ArgumentList "/i `"$msifile`" TARGETVDIR=`"$TARGETVDIR`" TARGETAPPPOOL=`"$TARGETAPPPOOL`" /qn /L* `"$logPath`"" -Wait
}
}
catch {
Write-Error $_.Exception.Message.ToString()
}
}
end {}
}
And code in main script
Invoke-Command -ScriptBlock {
. InstallFunctions.ps1
ManageMsi -msiFile $msiFile -operation InstallService -TARGETVDIR $vdir } -ComputerName $servName
Function ManageMsi work fine on local machine. Thanks for any answers
Edit: When i use
$session = New-PSSession -ComputerName $servName
Enter-PSSession $sesion
then in remote machine
msiexec /i "SomeSetup.msi" TARGETVDIR="SomeVDir" TARGETAPPPOOL="DefaultAppPoll" /qn /L* logMsiTest.txt
I've got this error (sorry about format above)
T h e W i n d o w s I n s t a l l e r S e r v i c e c o u l d n o t b e a c c e s s e d . T h i s c a n o c c u r i f t h e W i n d o w s I n s t a l l e r i s n o t c o r r e c t l y i n s t a l l e d . C o n t a c t y o u r s u p p o r t p e r s o n n e l f o r a s s i s t a n c e .