Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 175326

Invoke-VMScript install App as an administrator

$
0
0

My requirement is to install app using msiexec, I have referred

Re: Invoke-VMScript to run ps commands as an administrator

 

and other posts on this forum and tried the solution mentioned but am still getting few errors. I have tried all these below options after disabling UAC.

 

I tried following options:

Option1:

$ScriptBlock = @"

`$proc = Start-Process -PassThru -FilePath `"c:\windows\system32\msiexec`" -ArgumentList `" /i C:\Users\XRAY\MyApp.msi /qb /norestart /passive HASH=b64ba17a00ee671df MyAppParam2=Param2 MyAppParam3=Param3 MyApp=support@MyApp.com /L*V C:\Users\XRAY\install.log`" -Wait

return `$proc.ExitCode

"@

Invoke-VMScript -VM $TARGET_VM -ScriptText $ScriptBlock

Output: 1603 error - A fatal error occurred during installation. But if I try the same command on the VM powershell it works fine.

 

Option2: Tried with elevated access as I need to move a file from home directory to

$ScriptBlock = @"

function Elevate-Process  {

param ([string]`$exe = `$(Throw "Pleave provide the name and path of an executable"),[string]`$arguments)

`$startinfo = new-object System.Diagnostics.ProcessStartInfo

`$startinfo.FileName = `$exe

`$startinfo.Arguments = `$arguments

`$startinfo.verb = `"RunAs`"

`$process = [System.Diagnostics.Process]::Start(`$startinfo)

}

Elevate-Process -Exe powershell.exe -Arguments `"-noninteractive -command msiexec  /i C:\Users\XRAY\MyApp.msi /qb /norestart /passive HASH=b64ba17a00ee671df MyAppParam2=Param2 MyAppParam3=Param3 MyApp=support@MyApp.com /L*V C:\Users\XRAY\install.log`"

"@

Invoke-VMScript -VM $TARGET_VM -ScriptText $ScriptBlock

Output: Exception calling "Start" with "1" argument(s): "This operation requires an interactive window station"

 

Any suggestions please?


Viewing all articles
Browse latest Browse all 175326

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>