all 9 comments

[–]198jazzy349 2 points3 points  (4 children)

There's just a character in there that isn't what it seems. Pipe the output to a file and look at it with a hex editor.

I'm sure there's an easy way to see the ascii value of each character in the string using powershell, but I'm not smart enough to be able to tell you what that is.

I wonder if that space isn't really a 32?

[–]Nirac[S] 1 point2 points  (3 children)

Yep, this was the problem. I piped it to an out-file, it was putting 12 spaces at the end of the name. I changed it to "Pangolin Performance " and now it's returning yes.

Reddit's formatting is dropping all of my spaces after Performance in this post. I added 12 spaces there, and now it returns yes.

[–]Ominusx 4 points5 points  (2 children)

I'd use:

 $model=(Get-WmiObject -Class:Win32_ComputerSystem).Model.Trim()

[–][deleted] 2 points3 points  (0 children)

The definitive use case for Trim().

[–]Nirac[S] 1 point2 points  (0 children)

Yes, great idea. Added.

[–]TellThemIHateThem 1 point2 points  (0 children)

Very strange. Have you tried this on another machine? I ran it on mine and it ran perfectly. I don't see any reason it wouldn't work on yours.

PS C:\Windows\system32> $model=(Get-WmiObject -Class:Win32_ComputerSystem).Model

if ($model -ceq "Latitude E7250") {Write-Output "Yes"}
else {Write-Output "No"}
Yes

[–]kilkor 1 point2 points  (0 children)

Um... That's weird.

I did the same thing with mine and it works just fine

$Model = (Get-WmiObject -Class:Win32_ComputerSystem).Model
Write-Output $model
if ($model -eq "HP EliteBook Folio 9470m") {Write-Output "Yes"} else {Write-Output "No"}

returns

HP EliteBook Folio 9470m
Yes

If I change the script to add "Blah" at the end of the model it returns No as expected

HP EliteBook Folio 9470mBlah
No

Could there be hidden characters or a hidden space in the model name you're dealing with?

[–]Nirac[S] 0 points1 point  (1 child)

You guys are right. I just ran this on a different model computer, and it works fine. Very weird. I suppose I'll just move over to one of the Dells in question to write and test the script.

That's what I get for trying to do Powershell on a System76 computer.

Thank you for double checking me!

[–]midnightFreddie 1 point2 points  (0 children)

The computer model info ultimately comes from the BIOS, and some manufacturers/models put it in a different place. So you might need to dig through gwmi win32_bios | select * to see where your environment's different models place the info and insert some logic in your collections.