mercredi 14 mars 2018

Powershell not getting the write variable

so i'm new to powershell and i'm training myself by doing my first script with a menu, and from time to time i'm adding stuff to understand and learn new things

so now i have a question, when the user is asked to input a choice, let say number 1, he then will get asked to input a number of pc's that will be pinged

i'me tring to get something like "if the pc is alive" the user will get answer "the pc is alive"

here is the code:

$mypc = read-host -prompt "what is the name of the pc?"

Test-Connection -ComputerName $mypc -Count 1

if ($mypc = $true) {

write-host "the $mypc is alive"

}

and i'm not getting the right answer

this is what i'm getting after successful "test-connection"

the True is alive

ps: please direct me to the right code, i want to figure it by myself

thanks alot !

Aucun commentaire:

Enregistrer un commentaire