我有一个名为
我已编写了Powershell脚本以调用
当脚本执行时,该方法能够成功登录。我可以在数据库中看到会话ID的详细信息,但是我无法通过脚本获取会话ID的详细信息。变量
请告诉我如何从该方法中获取会话ID值。
GoLogon
的方法,它属于一个名为BS.Logon
的COM对象,需要5个参数:
- 用户名
- 密码
- 应用程序ID
- XML根节点
- IP地址
我已编写了Powershell脚本以调用
GoLogon
方法,如下所示。$obj=New-Object -ComObject BS.Logon
$sessionid=$obj.GoLogon([ref]$bUsername,$bPassword,$appid,$xmlroot,[ref]$ipad)
Write-Host $sessionid
当脚本执行时,该方法能够成功登录。我可以在数据库中看到会话ID的详细信息,但是我无法通过脚本获取会话ID的详细信息。变量
$sessionid
返回空值。此外,脚本抛出异常。Exception calling "GoLogon" with "5" argument(s): "Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))"
At E:\Logon.ps1:18 char:1
+ $obj.Login([ref]$bUsername,$bPassword,$appid,$xmlroot,[ref]$ipad)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation`
堆栈跟踪如下:
Exception : System.Management.Automation.MethodInvocationException: Exception calling "GoLogon" with "5" argument(s): "Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))" ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
--- End of inner exception stack trace ---
at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, PSMethodInvocationConstraints invocationConstraints, Object[] arguments)
at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
at System.Management.Automation.Interpreter.DynamicInstruction 7.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : ComMethodTargetInvocation
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, E:\Logon.ps1: line 18
PipelineIterationInfo : {}
PSMessageDetails :
请告诉我如何从该方法中获取会话ID值。