SSIS PowerShell Executable not adding Date to the file name

33 Views Asked by At

In my SSIS package I’m running a Execute Process Task with the Executable PowerShell.exe.

The Arguments is: Get-ChildItem -Path '\servername.com\PRD\SourceFiles' -Depth 6 -Include . -Recurse | Select FullName,Name,LastWriteTime | Export-Csv '\servername.com\ExportFiles\SourceFileDetails_$((Get-Date).ToString("yyyyMMdd")).txt' -Delimiter '|' -NoTypeInformation

What I need is the current date added to the file name but I’m getting "SourceFileDetails_$((Get-Date).ToString(yyyyMMdd)).txt" it will not pull the date.

I’m not sure how I go about adding the date to the file.

Tried: Get-ChildItem -Path '\servername.com\PRD\SourceFiles' -Depth 6 -Include . -Recurse | Select FullName,Name,LastWriteTime | Export-Csv '\servername.com\ExportFiles\SourceFileDetails_$((Get-Date).ToString("yyyyMMdd")).txt' -Delimiter '|' -NoTypeInformation

Expecting: SourceFileDetails_20230303.txt

The following works from PowerShell but not in SSIS.

Get-ChildItem -Path '\servername.com\PRD\SourceFiles' -Depth 6 -Include . -Recurse | Select FullName,Name,LastWriteTime | Export-Csv "\servername.com\ExportFiles\SourceFileDetails_$((Get-Date).ToString("yyyyMMdd")).txt" -Delimiter '|' -NoTypeInformation

When I run it in SSIS the following error happens. Error: In Executing "PowerShell.exe" "Get-ChildItem -Path '\servername.com\PRD\SourceFiles' -Depth 6 -Include . -Recurse | Select FullName,Name,LastWriteTime | Export-Csv "\servername.com\ExportFiles\SourceFileDetails_$((Get-Date).ToString("yyyyMMdd")).txt" -Delimiter '|' -NoTypeInformation" at "", The process exit code was "1" while the expected was "0".

0

There are 0 best solutions below