Avatar of Kamalasekar Parthasarathy
Kamalasekar Parthasarathy
Flag for India asked on

Power script a Beginner need help

Hi All,

Am a beginner to Powershell..
Can some one please explain whats wrong with the below powershell script


$strcom = read-host "Enter the name"

if ($strcom = 2)
{
      Write-host "You are the best"
}
Elseif ($strcom = 1)
{
        Write-host "You ugly hell"      
}
Else
{
  Write-host "You have entered the wrong number we got only 1 & 2 choices"

}
Powershell

Avatar of undefined
Last Comment
SubSun

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
SubSun

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dan Craciun

In powershell type:

help about_comparison_operators

This will get you a very long and thorough description of comparison operators.

PS: unlike batch, PS has a very well done help system that's available in command line.
Run update-help first to download a copy of help files on your computer.

HTH,
Dan
SubSun

@sekar_raj32, Could you please explain, why you have selected DanCraciun's comment as the sole answer?
Kamalasekar Parthasarathy

ASKER
@subsun am really sorry..it was my mistake..i have wrongly given it ..
Am extramely sorry..Actually you helped me but my bad..Am sorry again..
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Dan Craciun

@sekar_raj32: then contact a moderator and ask him to correct the situation.

I actually thought you preferred to read the help file and get a thorough understanding, instead of a "do this" solution :)
Kamalasekar Parthasarathy

ASKER
Thanks All
SubSun

Thank you sekar_raj32 for accepting the solution. Any specific reason for 'B' grade?

Please see the EE guidelines on grading..
Http://support.experts-exchange.com/customer/portal/articles/481419
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.