从 Perl 执行 Powershell [英] Executing Powershell from Perl

查看:51
本文介绍了从 Perl 执行 Powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆需要从 Perl 运行的 Powershell 脚本.我有以下代码,但由于某种原因,Powershell 脚本没有被调用.我已经尝试了反引号和系统命令

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);

请帮帮我.

推荐答案

你需要使用 -File 而不是 -Command

You need to use -File instead of -Command

这篇关于从 Perl 执行 Powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆