Best way to check if an PowerShell Object exist?

前端 未结 7 2003
无人及你
无人及你 2020-12-10 10:19

I am looking for the best way to check if a Com Object exists.

Here is the code that I have; I\'d like to improve the last line:

$ie = New-Object -Co         


        
7条回答
  •  有刺的猬
    2020-12-10 10:52

    I would stick with the $null check since any value other than '' (empty string), 0, $false and $null will pass the check: if ($ie) {...}.

提交回复
热议问题