【问题标题】:SSIS Execute process task and Powershell for expand filesSSIS 执行进程任务和 Powershell 用于展开文件
【发布时间】: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


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2015-02-16
      • 1970-01-01
      • 1970-01-01
      • 2019-09-12
      • 2019-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多