Perl:无法加载模块

时间:2017-06-16 03:53:02

标签: perl powershell

我正在使用这个PowerShell::Cmdlet模块从perl脚本运行powershell命令,但我一直收到此错误,即使我已将模块放在lib文件夹中

  

Can't locate object method "new" via package "PowerShell" at

use strict;
use warnings;
use PowerShell::Cmdlet;

my $res ;

my $command = PowerShell
->new('Get-ChildItem', [Image => '\\host1\det\mws\cm\seq\ws\*\*\*'])
->command();
 my $result = `$command`;

1 个答案:

答案 0 :(得分:0)

我相信你对getchilditem(图像而不是路径)使用了错误的参数,并且应该像@ikegami提到的那样将模块更改为PowerShell。可以试试这个:

use strict;
use warnings;
use PowerShell;

my $res ;

my $command = PowerShell
->new('Get-ChildItem', [Path => '\\\\10.0.0.1\\testshare\\'],[include => '*.txt'],[recurse => ''])
->command();
 my $result = `$command`;

print($result)