SSIS执行流程任务和Powershell扩展文件

时间:2018-07-19 19:09:44

标签: powershell ssis ssis-2016

我正在尝试执行Powershell脚本(该脚本正在解压缩源路径中与.zip文件夹同名的文件夹)

powershell脚本:

param([string] $ sourcepath) $ sourcepath =“ F:\ Worflow \”

函数解压缩($ file){

$ dirname = $ sourcepath +(Get-Item $ file).Basename

New-Item -Force -ItemType目录-Path $ dirname

expand-archive -path $ file -DestinationPath $ dirname -F

}

$ zipFiles = Get-LongChildItem -Path $ sourcepath -Recurse |哪里对象{$ _。Name -like“ * .zip”}

foreach($ zipFiles中的$ file)    {    解压缩($ file)

}

SSIS执行过程任务参数:

“-ExecutionPolicy不受限制-文件C:\ MyDataFiles \ Unzip.ps1”

在PS实例中运行时,powershell脚本运行正常。但是代码从SSIS任务失败并出现错误: Get-LongChildItem:术语“ Get-LongChildItem”不能识别为cmdlet,函数,脚本文件或 可操作的程序。检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后尝试 再次。 在C:\ MyDataFiles \ Unzip.ps1:17 char:13 + $ zipFiles = Get-LongChildItem -Path $ sourcepath -Recurse | Where-Obj ... + ~~~~~~~~~~~~~~~~~     + CategoryInfo:ObjectNotFound:(Get-LongChildItem:String)[],CommandNotFoundException     + FullyQualifiedErrorId:CommandNotFoundException

任何帮助将不胜感激。目标是使用Powershell压缩和解压缩文件夹或文件。

1 个答案:

答案 0 :(得分:0)

好像您在不先加载模块的情况下尝试使用命令。

Get-LongChildItem是开源模块PSAlphaFS的一部分

尝试首先在脚本中导入模块。 当然也需要安装它。 ;)

相关问题