FN-GM Posted September 6, 2013 Posted September 6, 2013 Hi, I would like it so when you run a power shell script that it will present 4 options to the end user. Depending on what option the user picks it will then run 1 command. all 4 options will have different commands. Does that make sense please? Thanks
jamesb Posted September 6, 2013 Posted September 6, 2013 Makes sense, and simple enough really. Simple version below. Write-Host "Press 1 for option 1" Write-Host "Press 2 for option 2" Read-Host $command switch ($command) { 1 {do stuff for command 1} 2 {do stuff for command 2} default {Write-Host "Didn't recognise the command"} } If you want to force them to choose an option you can stick the whole thing in a while loop, and use the default case to set a variable so that it'll loop again. 1
jamesb Posted September 6, 2013 Posted September 6, 2013 No problem. Out of curiousity, what's it for?
FN-GM Posted September 6, 2013 Author Posted September 6, 2013 When we add a computer to AD we have a couple of things to do. Like create it in SCCM, add mac address and add a group. So making a little powershell script to speed the process up. The options will be Staff Desktop Staff Laptop Student Desktop Student Laptop Thanks 1
FN-GM Posted September 24, 2013 Author Posted September 24, 2013 hi @jamesb there is a slight error i notice it should be something like This: Write-Host "Press 1 for option 1" Write-Host "Press 2 for option 2" $command = Read-Host "Please Enter An Option" switch ($command) { 1 {do stuff for command 1} 2 {do stuff for command 2} default {Write-Host "Didn't recognise the command"} } Apart from that all is good and it seems to work Thanks
FN-GM Posted September 24, 2013 Author Posted September 24, 2013 Apart from that perfect Thanks again.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now