I will refer to code lines using the number 1-12, to make it easier to talk about the code.
On line 4-6 you’re setting your registry keys, before you have even come to the switch statement. Therefore you will always be creating the registry keys, no matter the value of $app.
Line 7-12 will make the code return (write as output, Write-Output) one of the item properties saved on line 4-6, depending on the value of the $app variable, or at least could have. However, -eq doesn’t do pattern matching and the “*” character is not a valid character in a file name, so I’m guessing you really want to a wildcard search. You should then write your switch statement similar to the following:
switch -Wildcard ($app) { "*trial_03*" { <# do trial 03 stuff here#> } "*support_03*" { <# do support 03 stuff here#> } "*trial_01*" { <# do trial 01 stuff here#> } }
Additionally, on line 3 you’re setting the $computername variable, but you’re using it the line before, on line 2. I’m guessing this is not what you want to do, so these lines should probably swap places.