开发者

Executing Powershell from Perl

I have a bunch of Powershell scripts which I need to run from Perl. I have the following code but for some reason the Powershell scripts dont get invoked. I have tried both the backtick and the system command

$path = "C:/Users/PSScript.ps1";
$pwspath = "c:/windows/system32/windowspowershell/v1.0/powershell.exe";

$output = `$pwspath -command $path`;

system($pwspath -command $path);

Please help 开发者_StackOverflowme out here.


You need to use -File instead of -Command


Are you sure your code is formatted correctly? Shouldn't you be using quotes?

system("$pwspath -command $path");

Backtick should work, try:

my @stdout = `$pwspath -command $path`;
print join("\n", @stdout),"\n";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜