I can able to run the following script in localmachine, but when i execute this in windows server 2008 i get the following error. Powershell v2.0 has been installed in both local as well as in server. Please help me in solving this issue.
The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script blo
ck or CommandInfo object.
At E:\archive.ps1:8 char:3
+ & <<<< $WinRar a -ep2 -m5 -r -t "$ArchivePath\$ArchiveFile
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : BadExpression
$DateFolder = (Get-Date).AddDays(-$Days).tostring('yyyyMMdd')
&$WinRar a -ep2 -m5 -r -t "$ArchivePath\$ArchiveFileName" "$Path"