Passing variables to a powershell script within a SSIS package
<p>I am trying to pass a SSIS variable into a PowerShell script that is running via a Process Task within SSIS, im using SSIS 2008 if that makes any difference </p>

<p>Here is a copy of the powershell script im using that runs fine when executed with hardcoded values </p>

<pre><code>param ([string]$SourceServer, [string]$DestinationServer, [string]$Filename )

$SourceServer = "SERVERA"
$DestinationServer = "SERVERB"
$Filename = "DbNAME.mdf"

$SourcePath = "\D$\Data\"
$DestinationPath = "\D$\Data\Backups\"

$Source = '\\' + $SourceServer + $SourcePath + $Filename
$Destination = '\\' + $DestinationServer + $DestinationPath + $Filename

copy-item -path $Source -destination $Destination -verbose
</code></pre>

<p>I can get the PowerShell script to run fine if I hardcode the param's , however as soon as I change it to a variable the variable value isn't being passed through </p>

<p>Within the process task this is the executable </p>

<pre><code>"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
</code></pre>

<p>The arguments string is being built correctly so I know the variable value is being passed in </p>

<pre><code>-ExecutionPolicy Unrestricted -File "C:\Qarefresh.ps1" "DbaseA.mdf"
</code></pre>

<p>And here is the code for the expression </p>

<pre><code>"-ExecutionPolicy Unrestricted -File \"" +  "C:\\Qarefresh.ps1\" \"" + @[User::QA_FileName] + "\""
</code></pre>

<p>I'm relatively new to PowerShell so apologise if I have missed something basic , but i'm close to pulling out my hair with this one </p>

<p>Thanks in advance for any help given </p>