title: powershell - Invoke-Command : The value of the FilePath parameter must be a Windows PowerShell script file
body: <p>I have a re-usable script that I've been using with success calling a remote ps1 file but now I'm trying to call a remote batch file and I get the following error message - </p>
  
  <pre><code>Invoke-Command : The value of the FilePath parameter must be a Windows
  PowerShell script file. Enter the path to a file with a .ps1 file name
  extension and try the command again.
  </code></pre>
  
  <p>This is the script - </p>
  
  <pre><code>#Admin Account 
  $AdminUser = "domain\svc_account" 
  $Password = Get-Content D:\scripts\pass\crd-appacct.txt | convertto-securestring
  $Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminUser, $Password 
  $FileName = "runme.bat"
  $ItemLocation = "D:\path\to\bat\"
  
  #Invoke Script Remotely
  Invoke-Command -ComputerName Servername -filepath "$ItemLocation$FileName" -Authentication CredSSP -Credential $Credential
  </code></pre>