【发布时间】:2018-12-28 00:54:29
【问题描述】:
我正在尝试执行一个 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 | Where-Object {$_.Name -like "*.zip"}
foreach($zipFiles 中的$file) { 解压($文件)
}
SSIS 执行过程任务参数:
"-ExecutionPolicy Unrestricted -File C:\MyDataFiles\Unzip.ps1"
powershell 脚本在 PS 实例中运行正常。但是代码从 SSIS 任务中失败并出现错误: Get-LongChildItem :术语“Get-LongChildItem”未被识别为 cmdlet、函数、脚本文件或 可运行的程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确并尝试 再次。 在 C:\MyDataFiles\Unzip.ps1:17 char:13 + $zipFiles = Get-LongChildItem -Path $sourcepath -Recurse |哪里-Obj ... + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-LongChildItem:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
任何帮助将不胜感激。目标是使用 powershell 压缩和解压缩文件夹或文件。
【问题讨论】:
标签: powershell ssis ssis-2016