2016-12-13 2 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 

문제 윈도우 7 32 비트, 파워 쉘의 V4에서 모든 오류없이 100 %의 시간을 작동

. 윈도우 10 64 비트에서 , 그것은 시간의 약 5 % (PowerShell을 86를 강요하거나 실 거예요 전혀 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과 호환되지 않는 드라이버입니까? 아닙니다. 나는 이것이 파워 쉘 문제라고 상상할 수 없다. BMC에서 해결 한 응용 프로그램 자체가 시스템에서 제대로 작동합니까? –

+0

예 Excel에서이 DSN을 사용하는 Microsoft Query처럼 BMC 치료 응용 프로그램이 100 % 작동합니다. 아마도 AuditTrail과 같은 유일한 큰 필드에 주목해야합니다. 소가 집에 올 때까지 CaseID_를 가져올 수 있습니다. – TetraFlash

+0

쿼리는 64 비트 Excel 또는 32 비트 Excel에서 시간의 100 % 작동합니까? –

답변

0

입니다. 이것은 스크립트보다 드라이버 문제와 더 비슷합니다. 아직도 다른 64 비트 시스템에서 시도해보고 작동하는지 확인해 보길 권합니다. 그렇게하면 최소한 문제를 좁힐 수 있습니다.

희망을주고 싶습니다.

+0

불행히도 나는 Remedy 응용 프로그램이 완벽하게 기능하는 것처럼 작동하는이 드라이버가 붙어 있습니다. Microsoft Query를 사용하여 Excel에서 수행 한 것과 동일한 쿼리를 수행 할 수 있습니다. 좋은 게임을 원치 않는 Powershell도 있습니다. – TetraFlash

+0

고통을 이해할 수 있습니다. 그러나 실제로이 경우 나는 무력하다. 같은 스크립트가 매번 다른 출력을 낼 수 있습니다. 나는 BMC가 infra를 치료하는 테스트를 가지고 있지 않다. 나는 그것을 시험해야한다. –

0

나는 이전 방법이 실패하면서이 작품 왜 아무 생각이 없다, 그러나 이것은

$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) 
    write-host "Running Query" 
    ##### Start the database connection and set up environment 
    $DbString="DSN=AR System ODBC Data Source;UID=$userID;PWD=$password" 
    $DBConnection=New-Object System.Data.Odbc.OdbcConnection 
    $DBCommand=New-Object System.Data.Odbc.OdbcCommand 
    $DBConnection.ConnectionString=$DbString 
    $DBConnection.Open() 
    $DBCommand.Connection=$DBConnection 

    $SelectStatement="SELECT AuditTrail FROM HPD_HelpDesk WHERE AssignedToGroup='Group5'" 
    $DBCommand.CommandText=$SelectStatement 
    $DBResult=$DBCommand.ExecuteReader() 
    $UserTable=New-Object system.data.datatable 
    $UserTable.load($DBResult) 
    $UserTable 
    sleep 3 
} 

나는이 경우 이유에 대한 설명을 사랑을 작동하지만, 최소한의 작업 :