title: How do I check if a PowerShell module is installed?
body: <p>To check if a module exists I have tried the following:</p>
  
  <pre class="lang-powershell prettyprint-override"><code>try {
      Import-Module SomeModule
      Write-Host "Module exists"
  } 
  catch {
      Write-Host "Module does not exist"
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre class="lang-none prettyprint-override"><code>Import-Module : The specified module 'SomeModule' was not loaded because no valid module file was found in any module directory.
  At D:\keytalk\Software\Client\TestProjects\Export\test.ps1:2 char:5
  +     Import-Module SomeModule
  +     ~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ResourceUnavailable: (SomeModule:String) [Import-Module], FileNotFoundException
      + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
  
  Module exists
  </code></pre>
  
  <p>I do get an error, but no exception is thrown, so we see <code>Module exists</code> in the end, although <code>SomeModule</code> does not exist.</p>
  
  <p>Is there a good way (preferably without generating an error) to detect if a PowerShell module is installed on the system?</p>