I'm using SSIS 2016 in VS 2015.
I'm using PowerShell (I can never get C# to work how I want it) to spit out the results to a variable.
This is the code im running:
$RootFolder = 'C:\DSB_Download'
[string]$Folder = Get-ChildItem $RootFolder | sort Name -Descending| 
select -ExpandProperty Name -First 1;
If ([string]::IsNullOrEmpty($Folder))
    {
        $result = "EmptyFolder";
        $result = $result -replace "`t|`n|`r",""
        $result = $result -replace " ;|; ",";";}
    Else
    {$result = $Folder;}
Write-Output $result;
All im doing is trying to return a string of "EmptyFolder" to a Result variable, this is then used in a Script task, where im checking the DTS Variable , (made from the Powershell variable)
the c# is doing this:
 string NoFolders = "EmptyFolder";
        if (LocalDrive == NoFolders)
        {
            Dts.Variables["User::WorkingDateString"].Value = WebDrive;
        }
So the C# if clause is looking for the string "EmptyFolder"
Great, however when I'm debugging this, I've noted that the SSIS Variable that holds the PowerShell result shows as this:
So the String is showing with \r\n at the end, and of course this doesn't match what the c# is looking for and its passed over.
as you can see the PowerShell is trying to replace the $result to remove the \r\n but its not doing anything.
Does anyone have any ideas how I can get rid of this, and have the string variable exactly as it should be?

 
    