访问Python中的PowerShell参数

2024-03-29 00:46:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我的.ps1(PowerShell)脚本中有一组参数:

$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto( $bytes )
$DBUser = "myDBuser"
$DBPass = $password
$DBTNS = "myTNSname"
type $args[0] | sqlplus -s $DBUser/$DBPass@$DBTNS

我的机器的安全设置是“远程签名”。我使用一个测试sql对DB进行测试,它可以正常工作。所以我知道参数值传递正确,并且.PS1脚本运行正常。你知道吗

但是,我尝试在Python脚本中执行此操作,结果出现了一个奇怪的错误:

python Test.py
C:\PowerShell\run_sqlplus.ps1 : File C:\PowerShell\run_sqlplus.ps1 cannot be
loaded because running scripts is disabled on this system. For more information,
see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ C:\PowerShell\run_sqlplus.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

只是为了见鬼,我甚至试着使它不受限制,但仍然没有工作;因为如果这是问题的所在,那么测试.sql本来也应该失败的,但事实并非如此。 有什么建议吗?你知道吗


Tags: run脚本sql参数pluspasswordsystemmarshal