title: How to Invoke-Expression to call a function or script with variables?
body: <p>I get the an invalid path error with this script:</p>
  
  <pre><code>$buildZIP= 'starmatic'
  echo $buildZIP
  $command = ”\\XXXXXXXXXX\L$\Gopi_Prod_App\ToZipNew.ps1 $buildZIP”
  Invoke-Expression -Command $command
  </code></pre>
  
  <p>This is <code>ToZipNew.ps1</code>:</p>
  
  <pre><code>Param(
      [Parameter(Position=1, Mandatory=$true)]
      [ValidateNotNullOrEmpty()]
      [string]$build
  )
  echo "$build"
  $S = "L:\Gopi_Prod_App\$build\App_Data\*"
  $D = "\Gopi_Prod_App\Starmatic_UI.zip"
  
  echo $S
  echo $D
  
  Get-ChildItem "$S" | Compress-Archive -DestinationPath "$D" -Verbose
  #Compress-Archive -Path "$S" -CompressionLevel Fastest -DestinationPath "$D"
  </code></pre>
  
  <p>Error I am getting:</p>
  
  <pre>
  Compress-Archive : The path 'L:\Gopi_Prod_App' either does not exist or is not a
  valid file system path.  
  At \\XXXXXXXXXXX\L$\Gopi_Prod_App\ToZipNew.ps1:13 char:45 
  + ... t-ChildItem "$S" | Compress-Archive -DestinationPath "$D" -Verbose
  +                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
      + CategoryInfo          : InvalidArgument: (L:\Gopi_Prod_App:String) [Compress-Archive], InvalidOperationException  
      + FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Compress-Archive
  </pre>