2016-12-13 97 views
0

我的情况相当具体,所以我希望有人有一些洞察力可以帮助我。BMC Remedy AR驱动程序崩溃powershell

代码

$id = Get-Credential "REMEDY\$($env:USERNAME)" 
$userId = $id.UserName.split("\")[1].tolower() 
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($id.password) 
$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) 

$cn = New-Object -comobject ADODB.Connection 
$rs = New-Object -comobject ADODB.Recordset 
$b = "Group5" 
$c = "DSN=AR System ODBC Data Source;ARServer=remedyServer;ARServerPort=7130;UID=$userId;PWD=$password" 
$cn.Open($c) 
$q = "SELECT AuditTrail FROM HPD_HelpDesk WHERE AssignedToGroup='$b'" 
$rs.Open($q, $cn) 
while (!$rs.EOF) { 
    $rs.Fields.item(0).value 
    $rs.MoveNext() 
} 
$rs.close() 
$cn.close() 

司机:

Name: AR System ODBC Driver 
Version: 7.06.04.30000 
File: ARODBC7604_BUILD02.DLL 

问题

在Windows 7 32位,PowerShell的V4,一切正常的100%的时间没有错误。 在Windows 10 64位,它工作的时间约为5%(迫使PowerShell的x86或它不会看到的ODBC驱动程序可言,但是这更恼人的比一个问题)

错误

我的日子不好过即使出现错误也是如此,因为当发生这种情况时Powershell会立即完全关闭,但是从CMD运行它可以让我在关闭之前看到输出。这是我得到的错误,同样的代码偶尔也会有效。这实际上是崩溃的直线是$ rs.fields.item(0).value的线

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 
    at IDispatchInvoke(IntPtr , Int32 , INVOKEKIND , DISPPARAMS& , Variant& , ExcepInfo& , UInt32&) 
    at System.Management.Automation.ComInterop.UnsafeMethods.IDispatchInvoke(IntPtr dispatchPointer, Int32 memberDispId, INVOKEKIND flags, DISPPARAMS& dispParams, Variant& result, ExcepInfo& excepInfo, UInt32& argErr) 
    at CallSite.Target(Closure , CallSite , ComObject) 
    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) 
    at CallSite.Target(Closure , CallSite , Object) 
    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) 
    at System.Management.Automation.Interpreter.DynamicInstruction`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.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.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) 
    at System.Management.Automation.DlrScriptCommandProcessor.Complete() 
    at System.Management.Automation.CommandProcessorBase.DoComplete() 
    at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstreamCommandsToStop) 
    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) 
    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) 
    at System.Management.Automation.Interpreter.ActionCallInstruction`6.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.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess) 
    at System.Management.Automation.DlrScriptCommandProcessor.Complete() 
    at System.Management.Automation.CommandProcessorBase.DoComplete() 
    at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstreamCommandsToStop) 
    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) 
    at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper() 
    at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() 
    at System.Management.Automation.Runspaces.PipelineThread.WorkerProc() 
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Threading.ThreadHelper.ThreadStart() 
+0

这不就是与Windows 10不兼容的驱动程序吗?我无法想象这是一个PowerShell问题。 BMC补救应用程序本身是否在系统上正常工作? –

+0

是的BMC补救应用程序工作100%,就像在Microsoft Excel中使用此DSN的Microsoft Query一样。也许我还应该注意它唯一的更大的领域,比如AuditTrail,我可以将CaseID_拖到奶牛回家之前 – TetraFlash

+0

查询从64位Excel或32位Excel中100%的时间工作? –

回答

0

能否请您更新驱动程序,并检查它。这似乎更像是一个驱动程序问题,而不是脚本。不过我会建议你尝试一些其他的64位系统,看看它是否有效。这样,至少你可以缩小这个问题的范围。

希望它给你一个启发。

+0

不幸的是,我被这个驱动程序困住了,它的确如Remedy应用程序的功能一样工作,就像在Excel中使用Microsoft Query执行的相同的查询一样,它的Powershell不想播放很好 – TetraFlash

+0

我可以理解这种痛苦。但在这种情况下真的很无奈。同一个脚本每次如何产生不同的输出。我没有测试BMC补救措施。然后我必须测试它 –

0

我不知道为什么这个作品,而此前的方法失败,但这个工程

​​

我很想为什么是这种情况的解释,但至少它的工作:)