Octopus step to execute powershell script

I am trying to use octopus to do a backup before doing a publish. For this I am defining a step in projects steps options. Step type is run a powershell script. The following script I am passing it and setting the source and destination in variables.
param($source, $destination)

Get the date

$DateStamp = get-date -uformat “%Y-%m-%d@%H-%M-%S”
$destination = “$destination-$DateStamp”

#Check source dir exists or not
if (-not (test-path $source)) {throw “$source path does not exists”}

Alias for 7-zip

if (-not (test-path “C:\Program Files\7-Zip\7z.exe”)) {throw “C:\Program Files\7-Zip\7z.exe needed”}
set-alias sz “C:\Program Files\7-Zip\7z.exe”

############################################

Variables

sz a -t7z $Destination $Source
########### END OF SCRIPT ##########

Getting following error while running it through octopus.
2013-07-03 12:39:20 INFO Begin script run2013-07-03 12:39:20 DEBUG Running script against tentacle http://test05:10933/2013-07-03 12:39:22 INFO Job successful. Tentacle output follows:2013-07-03 12:39:21 INFO ERROR: Test-Path : Cannot bind argument to parameter ‘Path’ because it is null.2013-07-03 12:39:21 INFO ERROR: At C:\Users\test\AppData\Local\Tentacle\Temp\ead246ed-f184-465e-b798-d97a095b1abe.ps1:8 char:212013-07-03 12:39:21 INFO ERROR: + if (-not (test-path $source)) {throw “$source path does not exists”}2013-07-03 12:39:21 INFO ERROR: + ~~~~~~~2013-07-03 12:39:21 INFO ERROR: + CategoryInfo : InvalidData: (:slight_smile: [Test-Path], ParentContainsErrorRecordException2013-07-03 12:39:21 INFO ERROR: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom2013-07-03 12:39:21 INFO ERROR: mand2013-07-03 12:39:21 INFO ERROR:2013-07-03 12:39:21 INFO ==============================================2013-07-03 12:39:21 INFO PowerShell exit code: 02013-07-03 12:39:21 INFO ==============================================

Please guide what I am doing it wrong.

You don’t need the param($source, $destination) at the top.

I set $source and $destination as variables scoped to the PS step. When I included the param($source, $destination) it failed, without it it worked.

Here is the script I tested:
@@@

Get the date

$DateStamp = get-date -uformat “%Y-%m-%d@%H-%M-%S”
$destination = "$destination-$DateStamp"
write-host “Source” $source
write-host “Destination” $destination
@@@

And here’s the relevant section of the output log (much snipped for brevity):
2013-07-04 23:16:20 DEBUG - [destination] = 'c:\Backup’
2013-07-04 23:16:20 DEBUG - [source] = 'c:\Octopus\etc’
2013-07-04 23:16:21 INFO Source c:\Octopus\etc
2013-07-04 23:16:21 INFO Destination c:\Backup-2013-07-04@16-16-21

Thanks Trevor. Its working now.