troubleshooting Question

Problem running the powershell script in windows server 2008

Avatar of SQLM_M
SQLM_MFlag for India asked on
4 Comments1 Solution735 ViewsLast Modified:
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.

Error Message:

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\$ArchiveFileName" "$Path"
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression


$DateFolder = (Get-Date).AddDays(-$Days).tostring('yyyyMMdd')
&$WinRar a -ep2 -m5 -r -t "$ArchivePath\$ArchiveFileName" "$Path"
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros