VMware Cloud Community
TDRoy
Enthusiast
Enthusiast

Invoke-VMScript - Operation Not Allowed in Current State

$config_init ='

$rloc = "C:\Program Files\Path\Path2\"

Set-Location $rloc

.\app.exe

proprietary app.exe command #1

proprietary app.exe command #2

proprietary app.exe command #3

proprietary app.exe command #4

'

Invoke-VMScript -ScriptText $config_init -VM MyvM -GuestUser Administrator -GuestPassword Password

Also tried setting the location and running the app all in one like:

& "C:\Program Files\Path\Path2\app.exe"

Both return errors.

Any assistance would be great

Thank you

0 Kudos
9 Replies
LucD
Leadership
Leadership

Can you try adding the Verbose switch to the Invoke-VMScript cmdlet?

And share the output you see.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
TDRoy
Enthusiast
Enthusiast

It hangs here indefinitely after submitting the command:

VERBOSE: 7/27/2017 11:21:39 AM Invoke-VMScript Started execution

VERBOSE: Performing the operation "Invoke-VMScript" on target "RB"

VERBOSE: 7/27/2017 11:21:39 AM Invoke-VMScript Finished execution

When I run each of these commands letter for letter directly in PS it works perfectly.

Its as if Invoke-VMScript doesnt want to start reading the commands

0 Kudos
LucD
Leadership
Leadership

Those apps you are starting in the guest OS, they don't wait for some input or so?
Can you doing a simple script in the guest OS, perhaps just a Get-Service?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
TDRoy
Enthusiast
Enthusiast

The input is in the 'script' im passing through from Invoke-Script.

I can manually run through the commands word by word in a PS session on the guest, just not when starting from Invoke-Script

0 Kudos
LucD
Leadership
Leadership

I understand that, but can you just run a simple PowerShell cmdlet through the Invoke-VMScript cmdlet?

Just to be able to determine if it is a general Invoke-VMScript cmdlet issue, or something related to the actual script you are trying to run.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
TDRoy
Enthusiast
Enthusiast

Ah, sorry for the confusion. I have the Invoke-Script running elsewhere in a larger script properly, so it looks like its exclusively here that its not functioning properly.

Other instances include setting time in windows, netsh commands etc.

0 Kudos
LucD
Leadership
Leadership

Ok, so the issue is only happening on this station it seems.

Now to determine if it is a general Invoke-VMScript issue on that station, or something with the specific script you are running through Invoke-VMScript, can you run a simple one-liner, single cmdlet script on this station through Invoke-VMScript.

That's why I asked if you could run for example 'Get-Process' through Invoke-VMScript.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
TDRoy
Enthusiast
Enthusiast

Forgot to update on Friday..

The Get-Property or other commands worked with this piece. I ended up calling the commands individually like such and it works properly:

$scriptname = '

& 'Path\app.exe' command

& 'Path\app.exe' command

& 'Path\app.exe' command

'

Invoke-VMScript $scriptname

0 Kudos
LucD
Leadership
Leadership

Ok, good to hear Smiley Happy


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos