100 days of code: Day 23

I am tracking notes on PowerShell in PS1 files on my git hub repository. You can see all 100 days of code entries on the blog category page.

I actually started the lab questions for chapter 11 today. Actually it was somewhat humorous for the first one: use Get-NetAdapter to display all “non-virutal” network adapters e.g. those with “virtual” set to false.

Well I came with this command:

Get-NetAdapter | Where-Object Virtual -EQ false

No error but it doesn’t give me the right output. Actually it shows me the one virtual adapter. The opposite of what I’m looking for. I think I’d rather have an error. Although looking at the question again it does mention the specially defined $False constant. So if I try the same with that instead:

Get-NetAdapter | Where-Object Virtual -EQ $False

Okay so that one actually works.

But before I re-read the question just now I looked at the answer:

Get-NetAdapter -Physical

I mean alright that would logically work. But I don’t even see it in the list when I do Get-NetAdapter | gm. Or possibly my eyes are too tired to see that tiny text. In any case I guess I should have paid more attention to that minor detail with the $False. Or for sure it…does make sense just testing against “false” should work too?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s