question

YashimGreene-1087 avatar image
0 Votes"
YashimGreene-1087 asked ·

Powershell Creating WMI ComputerName Case statements

I have a bunch of batch scripts that I use to create WMI ComputerName Cases. I want to convert my batch scripts over to powershell scripts but I do not know how to create a ComputerName Lookup case with Powershell. Can I get some assistance with this issue? What I do in my Batch scripts is I create a WMI case that looks at the first 5 letters of the pc name and once it finds a match. I have a goto: for the first 5 letters of the computerName, based on the name it then runs the script associated to that computerName. It works great in my batch script. However, it is time to change to powershell, but I know when to ask for help. I have never created a case in powershell is have no idea what i am doing and could so help.

power-query-desktop
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MattiasAsplund-3483 avatar image
0 Votes"
MattiasAsplund-3483 answered ·

I'm not sure if you want help on Case (switch) statements and/or WMI scripting in Powershell. I'm guessing Case statements, so here is some code adressing that:

 $ComputerName = "ABCDE12345"
 switch ($ComputerName.Substring(0, 5))
 {
     "ABCDE" {
         Write-Host "Found it!"
     }
 }
· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So I need help. I need to create switches for 48 items. can you elaborate on this a bit more?

0 Votes 0 ·