Author Posts

May 15, 2017 at 12:51 pm

$arp = arp -a | Where {$_ -and $_ -notmatch 'internet address\s+physical address\s+type'}

What i dont get here is the "$_ -and $_ " part.
i get that this gets the output of arp -a and then brings back everything except the phrase in the regex.
i know the $_ is the piped data but i still dont understand that condition, help?

May 15, 2017 at 12:53 pm

That's not a really well-written Where clause, honestly.

It's saying, "where $_ contains something, and where $_ does not match the following regular expression."

I'd prefer:

$_ -ne $null -and $_ -notmatch 'internet address\s+physical address\s+type'

Or something a little more declarative.

May 15, 2017 at 1:00 pm

Thanks for the fast response i think ill implement it your way since it is more informative, can i use the PSItem instead of the $_? or it may cause some compatibility issues with other PS vers?

May 15, 2017 at 1:01 pm

$PSItem was introduced in v3.