title: Run parameters in a Powershell script from a batch file
body: <p>I'm trying to specify parameters in a powershell script, from a batch file.</p>
  
  <p>The script itself looks likes this:</p>
  
  <pre><code>    Param(
      [Parameter(Mandatory=$true,HelpMessage="Application switch")]
      [string[]]$Apps,
      [ValidateRange(3,9999)]
      [int]$SwitchDelay = 30
  
  $AppPids = @()
  $Windows = Get-Process | ? { $_.MainWindowTitle -ne "" }
  $Wsh = New-Object -COM Wscript.Shell
  
  foreach ($App in $Apps) {
      foreach ($Window in $Windows) {
          if ($Window.MainWindowTitle -like $App) {
              Write-Verbose "Vindusfilter ""$App"" found hit on ""$($Window.MainWindowTitle)"" med PID ""$($Window.Id)"""
             $AppPids += $Window.Id
          }
      }
  }
  
  do {
      foreach ($ID in $AppPIDS) {
          # Hides text...
          $Wsh.AppActivate($ID) | Out-Null
          Start-Sleep -Seconds $SwitchDelay
          Write-Verbose "Changed window to PID ""$ID"""
      }
  } while ($true)
  </code></pre>
  
  <p>And what I'm trying to do is to define in a batch file is something like:</p>
  
  <pre><code>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:\AppRotate.ps1" -Apps "*Chrome*", "Spotify*" -Switchdelay 5
  pause
  </code></pre>
  
  <p>(Supposed to show error message here, need more reputation first...)
  Error: "... PositionalParameterNotFound.Approtate.ps1"</p>
  
  <p>I'm basically new to scripting, so any ideas?</p>