1

I want to write a powershell-script which checks if a network interface card which uses receive side scaling uses a processor with a NUMA (Non-Uniform Memory Access) distance > 0.

What I've done so far:

$name = "Ethernet"
$adapter = Get-NetAdapterRss -Name $name

This outputs the RSS-Adapter processor data (together with other information) like:

RssProcessorArray: [Group:Number/NUMA Distance] : 0:0/0 0:2/0 0:4/0 0:6/0 0:8/0 0:10/0 0:12/0 0:14/0 0:16/0 0:18/0 0:20/0 0:22/0 0:24/32767 0:26/32767 0:28/32767 0:30/32767 0:32/32767 0:34/32767 0:36/32767 0:38/32767 0:40/32767 0:42/32767 0:44/32767 0:46/32767

As you see, the NUMA distance is the value behind the '/'. Now i want to retrieve it like:

foreach($processor in $adapter.RssProcessorArray) 
{
    Write-Host $processor.ProcessorGroup
    Write-Host $processor.ProcessorNumber
    Write-Host $processor.??
}

Somehow there is no ".NumaDistance" property on the object i get. How can i get this value for each processor in the list?

Tobias von Falkenhayn
  • 1,355
  • 5
  • 26
  • 59
  • Not an answer to the specific question, but I have created a [`ConvertTo-Expression` cmdlet](https://www.powershellgallery.com/packages/ConvertTo-Expression), that might help you to explore the `$adapter` object. Besides, I apparently do not have a nic with a `RssProcessorArray` (and I suspect many others might lack this), if you paste the [`PSON`](https://stackoverflow.com/questions/15139552/save-hash-table-in-powershell-object-notation-pson) content, more people might be able to help. – iRon Dec 01 '18 at 14:15

2 Answers2

3

Similar idea, but with regexp:

$str = (Get-NetAdapterrss -name "Ethernet" | Out-String).Split("`n") | where {$_ -like 'RssProcessorArray*'}
$rss =  $str | Select-String '\d+:\d+/\d+' -AllMatches
Write-Output $rss.Matches.Value
$rss.Matches.Value | foreach { ($_ -split "[:/]") -join "---" } #if need each value separetly
Mike Twc
  • 2,230
  • 2
  • 14
  • 19
1

Using static data as an example, but hope this helps

$text = 'RssProcessorArray: [Group:Number/NUMA Distance] : 0:0/0 0:2/0 0:4/0 0:6/0 0:8/0 0:10/0 0:12/0 0:14/0 0:16/0 0:18/0 0:20/0 0:22/0 0:24/32767 0:26/32767 0:28/32767 0:30/32767 0:32/32767 0:34/32767 0:36/32767 0:38/32767 0:40/32767 0:42/32767 0:44/32767 0:46/32767'

# split the text up on spaces
$firstSplit = $text.Split(' ')

# take all results starting at the first 0:0/0
# put into an array
[array]$processData = $firstSplit[4..($firstSplit.Count -1)]

# get just the data after the / for each item in the array
[array]$splitProcessData = $processData.split('/') | ? {$_ -notmatch ':'}

foreach($processor in $adapter.RssProcessorArray) 
{
    Write-Host $processor.ProcessorGroup
    Write-Host $processor.ProcessorNumber

    foreach($entry in $splitProcessData)
    {
        Write-Host $entry
    }
}
trebleCode
  • 2,134
  • 19
  • 34
  • Thanks for your reply, but how can I access the RssProcessorArray as a String for it is of type Microsoft.Management.Infrastructure.CimInstance[]? Sorry but I'm new to powershell. – Tobias von Falkenhayn Nov 21 '18 at 14:46
  • Do you get any data if you do `Get-NetAdapterRss -Name $name | Select-Object RssProcessorArray`? That field is blank on my machine, but you could cast it to a string afterwords or in the command itself: `(Get-NetAdapterRss -Name $name).ToString()` – trebleCode Nov 21 '18 at 15:07
  • I get an object of type MSFT_NetAdapter_RssProcessor. If i cast to string, it just outputs me: Microsoft.Management.Infrastructure.CimInstance[] – Tobias von Falkenhayn Nov 21 '18 at 15:21
  • Weird, noticed the same here. Must be due to the member type that RssProcessorArray has, which is `CimInstance#InstanceArray RssProcessorArray`. To the Google! – trebleCode Nov 21 '18 at 15:52