powershell - 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 压缩和解压缩文件夹或文件。
解决方案
看起来您正在尝试使用命令而不首先加载模块。
Get-LongChildItem 是开源模块 PSAlphaFS 的一部分
首先尝试在脚本中导入模块。当然也需要安装。;)
推荐阅读
- javascript - 循环中的 Onclick 函数使用循环的最后一次迭代而不是当前迭代
- javascript - 如何将引导列中图像的位置垂直更改几个像素
- jooq - JOOQ 强制类型无法通过 JPADatabase 代码生成生成 NUMERIC SQL 数据类型
- java - 使用自定义 Arraylist 更新 JList
- c - 将双整数指针转换为常规二维数组
- kotlin - 如何检查它是否是kotlin中的mac地址
- rust - 引入一条神奇的线后,第二个可变借用错误消失了
- php - Symfony - 为多个端点交付新旧更新对象
- python - 为一个数据框中的行列组合生成一个列表,其中第二个数据框中的数据包含更多列值组合
- hidden-markov-models - 如何为在线手写识别的HMM模型创建参数?