Search code examples
powershellpowercli

VMWare PowerCLI Invoke-VMScript


I would like to Invoke a command on a Remote VM using PowerShell with PowerCLI.

Invoke-VMScript -ScriptText "cmd /c calc" -ScriptType Bat -VM $VMName -GuestCredential $Credential -Confirm:$false -ea SilentlyContinue

Sadly everytime when my command get's invoked an Popup appears telling me "A Program running on this computer is trying to display a message" If click manually on that Popup my Script runs fine, but how can I automate this, so that I can use PowerCLI for this.

The goal is to execute a Binary in Interactive Mode, that processes Automated Tasks, when the Script get's invoked by "Invoke-VMScript"


Solution

  • This is an issue with Interactive Services Detection. Your script is trying to run as interactive in Session 0.

    The standard workarounds are creating a schedule task and then triggering it. Or invoking psexec.exe to the user session with -i.