|
Swink posted:How can I validate user input? I have a script that creates AD users, and I need to specify the users' location. There are four options, how can I ensure I dont misspell the city when I'm typing it in? Is there any way I could choose from a list of options rather than having to type? With parameters, you couldt use a validateset: code:
code:
code:
Jelmylicious fucked around with this message at 06:32 on Jun 27, 2012 |
# ¿ Jun 27, 2012 06:22 |
|
|
# ¿ May 21, 2024 16:04 |
|
Just to explain what Mario is saying here: Single quotes take everything as written, while double quotes interpret everything written. Backticks make thing that would be interpreted literal again. To illustrate:code:
|
# ¿ Jul 31, 2012 05:35 |
|
I believe that if you have an array and the next command accepts an array as input, it will just pass it as one thing. Not sure though.
|
# ¿ Aug 9, 2012 17:03 |
|
Didn't really look over your code, but your += is definitely in the wrong place. The following statements are the same:code:
|
# ¿ Dec 10, 2012 21:49 |
|
Then just sort the list you have:code:
code:
|
# ¿ Dec 17, 2012 14:32 |
|
An easy place to start, to get a good feel for how powershell starts, is Don's youtube channel: http://www.youtube.com/user/powershelldon This is from the same author as the month of lunches book. This might help you get a good grip on the quirks that are specific to powershell. If you only watch one video, use this deep-dive (warning, it is 4 hours long) https://www.youtube.com/watch?v=-Ya1dQ1Igkc
|
# ¿ Dec 20, 2012 09:27 |
|
|
# ¿ May 21, 2024 16:04 |
|
If you just put c:\script.ps1 in the task scheduler, it will execute it with the default associationg for ps1. So, your server will be very happy to oblige and just open notepad for you. Make sure you add powershell -file 'c:\script.ps1' to have it actually execute. Also, don't forget to put plenty of logging in the script, since you won't be monitoring it. See this for an example task: http://blogs.technet.com/b/heyscrip...ell-script.aspx
|
# ¿ Jan 17, 2013 18:12 |