Reputation: 1
Inside my guest VM, I have a PowerShell script that does some automation. However, I am trying to invoke that PowerShell script from outside using PowerCLI (inside PowerShell). Currently, my script works but instead of "running" the PowerShell script inside the guest VM, it opens it as a text file instead. Also, inside the guest VM, there is a interactive services detection that pops up when I call the below script. How can I resolve these issues?
add-pssnapin VMware.VimAutomation.Core
Connect-VIServer 192.168.1.29 # connects to vCenter
$vm = Get-VM -name 'CentOS 7'
$script = '"C:\Automation\StartServices.ps1"'
Invoke-VMScript -vm $vm -ScriptText $script -GuestUser 'user' - GuestPassword 'password' -ScriptType Powershell
Upvotes: 0
Views: 9753
Reputation: 1059
Use single, or double quotes for your $script
path but not both:
$script = 'C:\Automation\StartServices.ps1'
This seems to be the only issue. Tested & working in my PowerCLI
environment.
Upvotes: 1