+ -
当前位置:首页 → 问答吧 → powershell 运行脚本出错,

powershell 运行脚本出错,

时间:2011-12-14

来源:互联网

........

'@

$anError = $false;

[Reflection.Assembly]::LoadFile($psh + "\dll\Oracle.DataAccess.dll")

$conn= New-Object Oracle.DataAccess.Client.OracleConnection($oracleConstr);
$conn.Open();

#the first thing is lookup connection information for VCenter Server:
$sql = "SELECT sc.scsystem, sc.scIP, sc.scAccount, sc.scPassword FROM SystemConfigure sc WHERE sc.scsystem = 'vcenter'" + 
" OR sc.scsystem = 'firewall'" +
" OR sc.scsystem = 'unix command gateway'" ;

$vcenter = $null;
$unixServer = $null;
$firewall = $null;

.........


此脚本是在windows2003虚拟机里运行的,功能是用来产出虚拟机的,调用脚本执行。powershell脚本连接oracle数据库是ok的,调用dll\Oracle.DataAccess.dll文件也没有问题,但是连接后,走到$conn.Open()的时候报如下的错误。各位大虾看到后说下原因,在线跪求。。。

GAC Version Location  
--- ------- --------  
True v2.0.50727 C:\WINDOWS\assembly\GAC_32\Oracle.DataAccess\2.102.2.20__89b483f429c47342\Oracle.DataAccess.dll  
Exception calling "Open" with "0" argument(s): ""
At E:\powerShellScript\CreateVirtualMachineByVMOrderID.ps1:71 char:11
+ $conn.Open <<<< ();
  + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
 

作者: qingzhongren   发布时间: 2011-12-14

看了一下例子,好像很简单啊:
#connect to Oracle 
$constr = "User Id=system;Password=manager;Data Source=gh10gb"
$conn= New-Object Oracle.DataAccess.Client.OracleConnection($constr)
$conn.Open()


你是不是没设置$oracleConstr的值呢?

作者: askandstudy   发布时间: 2011-12-14