0

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".

Ern
  • 1
  • 1
  • Please [format your post properly](https://stackoverflow.com/help/formatting). – mklement0 Mar 07 '23 at 00:00
  • Try adding a period at beginning of the path. : '.\servername.com\PRD\SourceFiles' and ".\servername.com\ExportFiles\SourceFileDetails_$((Get-Date).ToString("yyyyMMdd")).txt" – jdweng Mar 07 '23 at 02:03
  • @jdweng Still the same results. SourceFileDetails_$((Get-Date).ToString(yyyyMMdd)).txt – Ern Mar 07 '23 at 14:22
  • hey, please format your question like this: https://stackoverflow.com/help/formatting – Amirali Eric Janani Mar 07 '23 at 21:55

0 Answers0