我有一个基于 Oracle 查询结果执行一些任务的 Powershell 脚本。
最近,我用一台装有 Win 8 的全新笔记本电脑更换了我的盒子,现在当我尝试运行我曾经使用的相同 powershell 脚本时,它无法正常工作。
现在我在 Powershell 中收到一条错误消息:
Exception calling "Open" with "0" argument(s): "ORA-12154: TNS:could not resolve the connect identifier specified
"
At C:\Users\User1\Desktop\BatchRun\ESS-QUEUE.ps1:146 char:5
+ $connection.Open()
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : OracleException
Exception calling "ExecuteReader" with "0" argument(s): "Invalid operation. The connection is closed."
At C:\Users\User1\Desktop\BatchRun\ESS-QUEUE.ps1:147 char:5
+ $users = $command.ExecuteReader()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
You cannot call a method on a null-valued expression.
At C:\Users\User1\Desktop\BatchRun\ESS-QUEUE.ps1:157 char:12
+ while ($users.Read()) {
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
我发现 Oracle 客户端丢失了,所以我设法让 TOAD Express 和 Oracle 客户端 10R2(32 和 64)正常工作。也就是说,我实际上可以毫无问题地运行 sqlplus.exe 和 TOAD。
谁能给我一个提示如何解决这个问题并使我的脚本再次工作?