Hi,
Tearing my hair out and looking for a bit of help :-)
I've a powershell script for checking memebers of the Local Adminstrators group on a server, and it works fine in a powershell window.(running it on the Server that is my VCO powershell host, and under the username/account registered with vCO...) However when I call it from a vCO workflow it fails.
To Track it down I isolated the offending code to this section:
I supply $servername as the Server to run the script against.
$group=[ADSI]"WinNT://$servername/Administrators"
$members=@($group.psbase.Invoke("Members"))
$results=$members | foreach{$_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null)}
and the highlighted Line is the specific code that fails.
the specific error is :
System.Management.Automation.MethodInvocationException: Exception calling "Invoke" with "2" argument(s): "The network path was not found.
I've noted that if I substitute $servername in the 1st line with "." ( ie run against the local server) It works fine. However, if I either use the $servername var, or just embed a specific servername it fails with the above error.
Any help appreciated,
Thanks in advance,
John.
(full error in the vCO log is:
2014-09-11 12:59:16.717] [I] PowerShellInvocationError: Errors found while executing script
System.Management.Automation.MethodInvocationException: Exception calling "Invoke" with "2" argument(s): "The network path was not found.
" ---> System.Runtime.InteropServices.COMException: The network path was not found.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_NativeObject()
at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
at System.Management.Automation.ScriptBlock.<>c__DisplayClassa.<InvokeWithPipe>b__8()
at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
at Microsoft.PowerShell.Commands.InvokeExpressionCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
(Dynamic Script Module name : invokeScript#14)