0

I'm setting up a RADIUS server and all works fine except for laptops with a certain Wireless NIC.

I managed to solve the problem, but I wish to have a list of all my AD Domain joined computers with the faulty/outdated NIC (all of our laptops are in several different OU's).

I was thinking something of combining the GET-ADcomputer -filter * (to list all computer objects) and combine this with the get-wmiobject win32_networkadapter | select netconnectionid, name | where name -eq "Intel(R) Dual Band Wireless-AC 8265"

The PS cmdlets work separately, but I want to match the get-wmiobject for each match triggered by the get-adcomputerCan you help me out ? :)

1
  • 1
    What powershell are you running? Use the newer Get-CimInstance. Other than that, you can use a loop of your choice to query against each Computer. $ComputerNames = Get-ADComputer -Filter * -Property Name |Select -Exp Name then, foreach ($Name in $ComputerNames) { Get-CimInstance -ComputerName $Name..., the rest should be logic on error checking if certain criteria isn't met, like not have a wireless NIC. Commented Jun 18, 2021 at 13:49

1 Answer 1

1

This is how you can approach your script. I do agree with Abraham's comment, if you can, use Get-CimInstance:

Get-CimInstance win32_networkadapter | Where-Object Name -EQ $match
$computers = Get-ADComputer -Filter *
$match = 'Intel(R) Dual Band Wireless-AC 8265'

$result = foreach($computer in $computers)
{
    $wmi = Get-WmiObject win32_networkadapter | Where-Object Name -EQ $match

    if(-not $wmi){ continue }
    
    [pscustomobject]@{
        ComputerName = $computer.Name
        NetconnectionID = $wmi.NetConnectionID
        Name = $wmi.Name
    }
    
}

$result | Export-Csv 'path/to/csv.csv' -NoTypeInformation

Edit

I haven't tested this nor I have a way of testing it right now, but if this works should be a lot faster, using query language:

$computers = (Get-ADComputer -Filter *).sAMAccountName
$match = 'Intel(R) Dual Band Wireless-AC 8265'
$filter = @{
    ComputerName = $computers
    Query = "SELECT NetConnectionID, Name FROM win32_networkadapter WHERE Name = '$match'"
}
Get-WmiObject @filter
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.