title: Powershell returns negative exit code while script results are correct
body: <p>I have made the following PowerShell script:</p>
  
  <pre><code>Set-Location D:\folder1\folder2\folder3\folder4;
  Get-ChildItem | Rename-Item -NewName {$_.BaseName.insert(19,'loadtime') + (Get-Date -Format HHmm) + $_.Extension};
  </code></pre>
  
  <p>The goal is to rename a file by adding loadtime at position 19 and a time stamp. While the results of running the scripts the following error message is returned:</p>
  
  <pre><code>Rename-Item : The input to the script block for parameter 'NewName' failed. 
  Exception calling "Insert" with "2" argument(s): "Specified argument was out 
  of the range of valid values.
  Parameter name: startIndex"
  At D:\folder1\folder2\folder3\folder4\folder5\RenameFile.ps1:2 
  char:38
  + Get-ChildItem | Rename-Item -NewName {$_.BaseName.insert(19,'loadtime') + 
  (Get-D ...
  +                                      
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (Archive:PSObject) [Rename-
  Item], ParameterBindingException
      + FullyQualifiedErrorId : 
  ScriptBlockArgumentInvocationFailed,
  Microsoft.PowerShell.Commands.RenameItemCommand
  </code></pre>
  
  <p>When I run the script from my SSIS package I get the following error:</p>
  
  <pre><code>[Execute Process Task] Error: In Executing "PowerShell.exe" "-F D:\folder1\folder2\folder3\folder4\folder5\exec RenameFile.ps1" at "", The process exit code was "-196608" while the expected was "0".
  </code></pre>
  
  <p>I have tried to search for this error message but I could not find a page talking about this specific exit code. </p>
  
  <p>The problem is though that while running the script commands from a PowerShell window I would still get the error message but the filename does change as expected. However since an error is returned the Execute Process Task in SSIS will fail. </p>
  
  <p>My question is, what is the cause of this error? I assume it has to do with:</p>
  
  <pre><code>{$_.BaseName.insert(19,'loadtime') + (Get-Date -Format HHmm) + $_.Extension};
  </code></pre>
  
  <p>Wherein  $<em>.BaseName.insert(19,'loadtime') and  (Get-Date -Format HHmm) and + $</em>.Extension are seen as separate arguments. 
  My knowledge of PowerShell is not too great so this is just speculation on my part. </p>
  
  <p>What would help me get rid of the error?</p>
  
  <p>Thanks in advance!</p>