by Lery at 2013-04-24 14:20:06
If I put this into my script:by mjolinor at 2013-04-24 14:36:02
HelpMessage=“Computer name or IP address to query”)]
It will prompt me for computername. I enter in the name or ip and hit enter. It then prompts me for computername. If I hit enter again it runs my script. Is there a syntax to make it just prompt me once. I enter in the computername and hit enter, and that is it. I’m not interested in entering in multiple computer names.
Change this:by Lery at 2013-04-24 15:53:39
Any time you see those nested square brackets in a type, it’s designating an array of objects of that type. Without them, it means a single object.
Any time you see those nested square brackets in a type, it’s designating an array of objects of that type. Without them, it means a single object.[/quote]
Is it better to do that or this:
#$a = Read-Host “Please Enter Computer Name or IP Address”
#$computername = $a
The code just above seems to work better in the manner of running the script by right clicking and choose run with powershell. As opposed to the parameter code. When I right click on the script when it utilizes a parameter, it just opens and closes. I have to actually launch from within Powershell. Which is OK in some circumstances. I also like the Read-Host because it looks a little nicer than a prompt saying computername:. Am I breaking any rules by using the read-host command?