title: Suppress Error Messages in PowerShell at get-package
body: <p>I use PowerShell to check, if specific apps are installed on the users PC:</p>
  <pre><code>$Application_MicrosoftEdge   = get-package &quot;Microsoft Edge&quot; | % { $_.metadata['installlocation'] }
  $Application_Microsoft365    = get-package *&quot;Microsoft 365&quot;* | % { $_.metadata['installlocation'] }
  Write-Host &quot;Microsoft Edge Path    : $Application_MicrosoftEdge&quot;
  Write-Host &quot;Microsoft 365 Path     : $Application_Microsoft365&quot;
  </code></pre>
  <p><strong>This works quiet well</strong>, but if an application is not installed on the users PC, then an error message is shown (here &quot;Microsoft 365&quot; is not installed on the PC):</p>
  <pre><code>get-package : Für &quot;*Microsoft 365*&quot; wurde kein Paket gefunden.
  In D:\Scripts\GetInstalledApp.ps1:12 Zeichen:32
  + $Application_Microsoft365    = get-package *&quot;Microsoft 365&quot;* | % { $ ...
  +                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
      + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
  </code></pre>
  <p>I tried the following way, but here an error message is shown:</p>
  <pre><code>Try {
    $Application_MicrosoftEdge   = get-package &quot;Microsoft Edge&quot; | % { $_.metadata['installlocation'] }
     $Application_Microsoft365    = get-package *&quot;Microsoft 365&quot;* | % { $_.metadata['installlocation'] }
  }
  Catch {
    # Place action on error here
  }
  </code></pre>
  <p>I also tried to wrap it in <code>$( ... ) | out-null</code> to suppress the error, but this is also not working.
  `
  Any idea?</p>