首页 > 解决方案 > SSIS 执行进程任务和 Powershell 用于展开文件

问题描述

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

PowerShell脚本:

参数([字符串] $sourcepath) $sourcepath = "F:\Worflow\"

功能解压缩($文件){

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

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

展开存档 -path $file -DestinationPath $dirname -F

}

$zipFiles = Get-LongChildItem -Path $sourcepath -Recurse | Where-Object {$_.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 压缩和解压缩文件夹或文件。

标签: powershellssisssis-2016

解决方案


看起来您正在尝试使用命令而不首先加载模块。

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

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


推荐阅读