title: How to require command-line arguments (not parameters) in the PowerShell?
body: <p>Different from: <a href="https://stackoverflow.com/questions/2157554/how-to-handle-command-line-arguments-in-powershell">How to handle command-line arguments in PowerShell</a></p>
  
  <p>What's the best way to handle an <strong>unnamed</strong> command-line argument in a powershell script?</p>
  
  <p>For example, I have a powershell script that I would like to run as</p>
  
  <pre><code>.\test.ps1 L3
  </code></pre>
  
  <p>and have an error if L3 is not supplied.  I don't want to have to run it as:</p>
  
  <pre><code>.\test.ps1 -lab L3
  </code></pre>
  
  <p>My current script:</p>
  
  <pre><code>$args[0] 
  </code></pre>
  
  <p>does not cause an error if the argument is omtted.</p>
  
  <p>This looks promising, haven't tried it yet:
  <a href="https://technet.microsoft.com/en-us/library/hh847743.aspx" rel="nofollow noreferrer">https://technet.microsoft.com/en-us/library/hh847743.aspx</a>
  <strong>* Edit: *</strong>
  The promising link is useful -- I used it to form all my examples</p>