Best way to check if an PowerShell Object exist?

前端 未结 7 2153
无人及你
无人及你 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:50

    Type-check with the -is operator returns false for any null value. In most cases, if not all, $value -is [System.Object] will be true for any possible non-null value. (In all cases, it will be false for any null-value.)

    My value is nothing if not an object.

提交回复
热议问题