I am using the default "Invoke an External Script" vCO workflow provided by the PowerShell plug-in.
I have set up my powershell server on the same Windows Server as vCO is installed in. I am able to run a simple PowerCLI script if I use the default "Invoke a PowerShell Script" workflow and it runs fine as the script is located internally to vCO.
However, now I'm attempting to call a simple PowerCLI script located external to vCO at c:\report.ps1 on the PowerShell server using the "Invoke an External Script" workflow.
When I try to do it this way, the workflow fails with the following output under "Logs":
[2014-01-28 19:42:32.447] [D] Invoke command in session 261371cc-3b28-45e3-bf6b-df7bddeeb2c9
[2014-01-28 19:42:33.181] [I] PowerShellInvocationError: Errors found while executing script
System.Management.Automation.RuntimeException: The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script block or CommandInfo object.
at System.Management.Automation.CommandNode.CreateCommandProcessor(Int32& index, ExecutionContext context)
at System.Management.Automation.CommandNode.AddToPipeline(PipelineProcessor pipeline, ExecutionContext context)
at System.Management.Automation.PipelineNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
(Dynamic Script Module name : invokeScript#14)
Any ideas?
Thanks!
Quick guess: wrong syntax for the file name: you have to use c:\\script.ps1 in Javascript, or c:/script.ps1.
And: make sure that vCO has the proper permissions to access the script file.
Cheers,
Joerg
Actually, it looks like the issue was that I needed to add the pssnapin for powerCLI to the .ps1 script itself. The workflow calls the powershell server, but not powercli, so it doesn't matter if powercli is installed on the powershell server, it doesn't have access to the powercli cmdlets.
Ich bin voraussichtlich ab dem 31.1.2014 wieder zu erreichen, E-Mails werden nicht weitergeleitet
I had a similar problem, turned out to be an issue with the supplied path to the script. While the workflow appears to suggest using a path containing quotes:
my supplied path of:
"C:\Scripts\Test.ps1" failed
Instead using (without quotes):
C:\Scripts\Test.ps1
was successful. So it would appear using paths without spaces to be a good idea.
Hope this helps.....