skip to Main Content

Get all the Network Interfaces

$nics = Get-AzNetworkInterface | ?{ $_.VirtualMachine -NE $null}

I am stuck on ?{ $_.VirtualMachine -NE $null} can anyone help?

2

Answers


  1. ? is an alias for Where-Object Cmdlet. That means

    $nics = Get-AzNetworkInterface | ?{ $_.VirtualMachine -NE $null}
    

    is equivalent to

    $nics = Get-AzNetworkInterface | Where-Object { $_.VirtualMachine -NE $null}
    

    Here Where-Object selects objects from a collection based on their property values and $_ is a variable to refer the current item in the collection.

    Login or Signup to reply.
  2. ?{ $_.VirtualMachine -NE $null}

    NE is Comparision Operator which means Not Equals and $_ means it is using the present item. So, it means finding those Virtual Machines which are not equal to null in the collection.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search