title: Substring in PowerShell to truncate string length
body: <p>Is it possible in PowerShell, to truncate a string, (using <code>SubString()</code>?), to a given maximum number of characters, <strong>even</strong> if the original string is already <strong>shorter</strong>?</p>
  
  <p>For example:</p>
  
  <pre><code>foreach ($str in "hello", "good morning", "hi") { $str.subString(0, 4) }
  </code></pre>
  
  <p>The truncation is working for <code>hello</code> and <code>good morning</code>, but I get an error for <code>hi</code>.</p>
  
  <p>I would like the following result:</p>
  
  <pre><code>hell
  good
  hi
  </code></pre>