title: How do I pass a computer name as a variable to the PowerShell -ComputerName from a batch file?
body: <p>I have been searching for the right answer without success.</p>
  
  <p>I have a batch file that executes a PowerShell Script.</p>
  
  <p>Batch file is;</p>
  
  <pre><code>PowerShell C:\scripts\GetStatus.ps1
  </code></pre>
  
  <p>PowerShell Script that works is;</p>
  
  <pre><code>Get-Service -Name svcUdpLogger -Computer Name server01 | Start-Service
  </code></pre>
  
  <p>What I am looking for is how do I pass the server01 as a variable into this script from a batch file.</p>
  
  <p>Depending on if a server service has stopped, this batch file would be run automatically to restart this service.</p>
  
  <p>I have tried using the following;</p>
  
  <pre><code>param([string]$computername=)
  </code></pre>
  
  <p>I keep getting invalid argument.</p>
  
  <p>Thanks,</p>
  
  <p>UPDATE - I think I have solved it. This may not be the correct way to do it, however it does work this way;</p>
  
  <pre><code>PowerShell C:\scripts\GetStatus.ps1 -ComputerName server01
  </code></pre>
  
  <p>If there is a  more elegant way to do it, I would appreciate the clarity!</p>
  
  <p>Thanks,</p>