lundi 26 août 2019

Not taking the Else-if input powershell with Switch statement

Hi need help with powershell code, I have to update a couple of Softwares using powershell,but getting errors while running the script, any help highly appreciated. 

inputs to the code are 1 and 0 for Switch condition and other inputs are foo,boo,Oracle to be updated , based on condition softwre will be updated

$param=Read-Host -Prompt "Enter the input 1 or 0" 
[bool]$upg=$true
$sftp=Read-Host "Please Enter the sftwre to update"
switch($param)
{
0{
Write-Output "Today is monday"
}
1
{
   $prm_prd=Read-Host -Prompt "Are you going for operation upgrade"
    if( $prm_prd -eq $upg)
    {
    Write-Output "System upgrade"

if ( $sftp -eq 'foo'){
Write-Output "foo upgrade"
}
else-if ( $sftp -eq 'boo' )
{
Write-output "boo upgrade"
}
else-if ( $sftp -eq 'Oracle' )
{
Write-output "oracle upgrade"
}
}
}
}

Aucun commentaire:

Enregistrer un commentaire