I am very very new to scripting. I need help where i can be on a directory and i want to be able to run commands that are shown in switch statement. Example
1: ipconfig “Runs ipconfig”
2: ls “lists all files from the directory”
3. cd … “goes back to previous directory”
Etc
So if i select or enter 1 then it will run that command and 2 will run its own command so i dont neccessairly have to type.
Although the purpose of this forum is to help others with their challenges there are a few issues with your request though.
This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.
We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.
Regardless of that … what’s your actual question? You description is quite vague.
I assume you’re refering to a menu where you can select an option, right?
How do you navigate to this directory?
How do you like to run your script?
How is that command related to any directory?
Why can’t you run it from any directory on the computer?
Only the names?
… or some of the meta data as well?
… maybe including the full path?
… what do you want to do with the listing?
What previous directory? I understood you run the script from the desired directory …
Entering 1 or 2 is already typing! … and how would you like to start your script actually?
The tasks you listed are actually that basic that I’m not sure if it’s really worth it to actually make them available via a menu. Depending on the purpose of your desired script it may be more feasable to create a custom module.
And finally to push you to a direction you may study the following links to get you started with scripting in PowerShell in general and how to create an interactive selection:
Don’t worry about the “old” version. The basics are still the same.
Still an excellent source if you want to look something up:
Every PowerShell coder should read this:
A general tip at the end - plerase always read the help for the cmdlets you’re about to use completely including the examples to learn ho to use them.