Automation

 View Only
  • 1.  Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 26, 2017 10:32 PM

    $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



  • 2.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 27, 2017 04:40 AM

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

    And share the output you see.



  • 3.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 27, 2017 06:54 PM

    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



  • 4.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 27, 2017 08:04 PM

    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?



  • 5.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 27, 2017 08:22 PM

    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



  • 6.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 27, 2017 08:39 PM

    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.



  • 7.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 27, 2017 09:04 PM

    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.



  • 8.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 28, 2017 05:08 AM

    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.



  • 9.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 31, 2017 03:28 PM

    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



  • 10.  RE: Invoke-VMScript - Operation Not Allowed in Current State

    Posted Jul 31, 2017 04:33 PM

    Ok, good to hear :smileyhappy: