I'm trying to do something like:
Get-WmiObject Win32_NetworkAdapterConfiguration `
-Filter "DefaultIPGateway!=NULL"
But I have an error:
Get-WmiObject : Invalid query At line:1 char:14 + Get-WmiObject <<<< Win32_NetworkAdapterConfiguration -Filter "DefaultIPGateway!=NULL" + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
It's strange, because when I try to get type of DefaultIPGateway values. It's System.Array for the existent values:
PS> $result[0].DefaultIPGateway.Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String[] System.Array
And a NULL for the nonexistent values:
PS> $result[1].DefaultIPGateway.GetType()
You cannot call a method on a null-valued expression.
At line:1 char:36
+ $result[1].DefaultIPGateway.GetType <<<< ()
+ CategoryInfo : InvalidOperation: (GetType:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Could someone help me to understand why my WQL doesn't work and what I should do to make it go?