My script is setting my variable rather than testing to it against a string:

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

If ($Model = "Latitude E6430")
{
Set-Location -Path \\contosofs\software$\"Dell Drivers"\"DELL LatE6430"\BIOS\

Copy-Item -Path E6430A21.exe -Destination C:\Temp

Set-Location C:\Temp

.\E6430A21.exe
}
elseif ($Model = "Latitude E6420")
{
Set-Location -Path \\contosofs\software$\"Dell Drivers"\"DELL LatE6420"\BIOS\

Copy-Item -Path Latitude_E6420_E6420ATG_A24.exe -Destination C:\Temp

Set-Location C:\Temp

.\Latitude_E6420_E6420ATG_A24.exe
} 
else {
Write-Host "Does not match known Bios Config Vulnerability"
}

Can someone help me so that it tries to match it?

3 Spice ups

You use ‘-eq’

= in powershell is ‘value’ assignment

# Assign
$model = 'Latitude E6430' 

# Compare
$model -eq 'something' # will give true/false result

# so you'd use:
If ($Model -eq "Latitude E6430"){
    # do stuff
}

https://ss64.com/ps/syntax-compare.html

5 Spice ups

Have you tried using -eq instead of = in your If statements?

2 Spice ups

I laughed because I’ve done exactly this, not once, but twice!

1 Spice up
$model=(get-wmiobject win32_computersystem).model
switch ($model) {
   "Latitude E6430" {"Yay, it's the one"; break}
   default {"Oh no"; break}
  }

Something like that and then between the { } you put the commands you want executed… To add more selections just copy the line starting with “Lattitude …”, paste it and change the selection criteria and then what has to be executed.

Info here

And why not start-process your way around this…

Set-Location C:\Temp

.\E6430A21.exe

You can even steal another line of code from it and do it like this

switch ($(get-wmiobject win32_computersystem).model) {
   "Your model" {"Yay, it's the one"; break}
   default {"Oh no"; break}
  }

@rebootssolveproblems

1 Spice up

Yeah just something to keep in mind using powershell, one of the many gotchas that you’ll forget once or twice

C is similar, if x=4 sets x equal to 4, while x==4 compares x and 4. And its not like it errors out, or gives warnings like “Hey I see you have an if statement but then you are assigning a value to a variable, are you sure you’ve had enough coffee today??”

2 Spice ups

too_much_coffee_gif_by_cartoonsbykristopher-d63ykpv.gif

Ha! I printed that .gif out and hung it in my cubicle. I can say I’m off to a good start since I can see the printout jittering!