Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Problems with using Switch statement

$
0
0

This script runs without error, but I don’t think the switch statement has been implemented correctly. The results apply all registry entries based on the lines of code in the switch block. It should “not” apply $RBM01, because it does not exist in $app.

Please help. Code below

New-Item -Path HKLM:\Software\Geneva\Warehousing -Name Packages
$app = get-childitem c:\install\$computername
$computername = (Get-WmiObject -Class Win32_ComputerSystem).__Server
$Bginfo = set-itemproperty -Path HKLM:\Software\Geneva\Warehousing\Packages -name ‘trial_03′ -value NOV0173
$RBM03 = set-itemproperty -Path HKLM:\Software\Geneva\Warehousing\Packages -name ‘support_03′ -value NOV01797
$RBM01 = set-itemproperty -Path HKLM:\Software\Geneva\Warehousing\Packages -name ‘trial_01′ -value NOV01796
switch ($app)
{
($app -eq ‘*trial_03*’) {$Bginfo}
($app -eq ‘*support_03*’) {$RBM03}
($app -eq ‘*trial_01*’) {$RBM01}
}


Viewing all articles
Browse latest Browse all 13067

Latest Images

Trending Articles



Latest Images