Passing Parameters to powershell script in scheduled task
<p>I am trying to create a scheduled task that will run a Powershell script with 1 parameter - this is on Server 2012 with Powershell v5 installed.  So far I have been able to get the task to run, but it doesn't recognize my param value - the value is null in my script that I am calling.  Here is what I have to create the scheduled task:</p>

<pre><code>$TicketTime = "9:00pm"
$EmpID = "1234"
$Firstname = "Test"
$Lastname = "User"

$Action = New-ScheduledTaskAction -Execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument "-ExecutionPolicy ByPass -File C:\Scripts\Term.ps1 -EmpID '$EmpID'"
$Trigger = New-ScheduledTaskTrigger -Once -At "03/29/2016 $TicketTime"
$Task = New-ScheduledTask -Action $Action -Trigger $Trigger -Settings (New-ScheduledTaskSettingsSet)
$Task | Register-ScheduledTask -TaskName "$Firstname $Lastname" -User "myuser" -Password "mypass"
</code></pre>

<p>This will execute successfully, but will not recognize the -EmpID parameter.  I have also tried -Command instead of -File for the Argument value but I get the same result.</p>

<pre><code>-ExecutionPolicy ByPass -Command "&amp; C:\Scripts\Term.ps1 -EmpID 1234"
</code></pre>

<p>Single quotes around the param doesn't seem to do anything either</p>

<pre><code>-ExecutionPolicy ByPass -Command "&amp; C:\Scripts\Term.ps1 -EmpID '1234'"
</code></pre>

<p>So far nothing I do will get the param to pass.  What am I missing?</p>