# Powershell script help plz

**URL:** <https://forums.powershell.org/t/powershell-script-help-plz/22685>\
**Category:** PowerShell Help\
**Created:** [July 29, 2023, 9:02pm UTC](https://forums.powershell.org/t/powershell-script-help-plz/22685 "2023-07-29T21:02:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aayusharma](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/aayusharma/32/4703_2.png) [@aayusharma](https://forums.powershell.org/u/aayusharma)\
**Post date:** [July 29, 2023, 9:02pm UTC](https://forums.powershell.org/t/powershell-script-help-plz/22685/1 "2023-07-29T21:02:00Z")

</div>

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.

Can someone please help me with this

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 29, 2023, 10:17pm UTC](https://forums.powershell.org/t/powershell-script-help-plz/22685/2 "2023-07-29T22:17:00Z")

</div>

Adambastola2,  
Welcome to the forum. 👋🏼

> [@aayusharma](#):
>
> Can someone please help me with this

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.

> [@aayusharma](#):
>
> where i can be on a directory and i want to be able to run commands that are shown in switch statement.

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? 🤔

> [@aayusharma](#):
>
> 1: ipconfig “Runs ipconfig”

How is that command related to any directory? 🤔  
Why can’t you run it from any directory on the computer? 🤔

> [@aayusharma](#):
>
> 2: ls “lists all files from the directory”

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? 🤔

> [@aayusharma](#):
>
> 1. cd … “goes back to previous directory”

What previous directory? I understood you run the script from the desired directory … 🤔

> [@aayusharma](#):
>
> enter 1 then it will run that command and 2 will run its own command so i dont neccessairly have to type.

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. 😉

> **[Getting Started with PowerShell 3.0](https://learn.microsoft.com/en-us/shows/getstartedpowershell3/)**
>
> This Jump Start is designed to teach the busy IT Professionals about this powerful management tool. Learn how PowerShell works and how to make PowerShell work for you from the experts Jeffrey Snover, the inventor of PowerShell, together with Jason...

Still an excellent source if you want to look something up:

> **[Windows PowerShell 4.0: TFM (The F\*\*\*\*\*\* Manual)](https://www.sapien.com/books_training/Windows-PowerShell-4)**
>
> The most comprehensive and authoritative Windows PowerShell book currently available.

Every PowerShell coder should read this:

> **[GitHub - PoshCode/PowerShellPracticeAndStyle: The Unofficial PowerShell Best...](https://github.com/PoshCode/PowerShellPracticeAndStyle)**
>
> The Unofficial PowerShell Best Practices and Style Guide - GitHub - PoshCode/PowerShellPracticeAndStyle: The Unofficial PowerShell Best Practices and Style Guide

> **[How to Create Prompts in PowerShell | Jeff Brown Tech](https://jeffbrown.tech/how-to-create-prompts-in-powershell/)**
>
> Did you know you can create custom prompts in PowerShell? Learn how to create these prompts using two different methods.

> **[Out-GridView (Microsoft.PowerShell.Utility) - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-gridview?view=powershell-7.3)**
>
> This cmdlet is only available on the Windows platform. The Out-GridView cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table. Because this cmdlet requires a user interface, it does not...

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.

🤟🏼

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:14pm UTC](https://forums.powershell.org/t/powershell-script-help-plz/22685/3 "2024-05-16T20:14:45Z")

</div>

Closed on May 16, 2024, 8:14pm UTC


