Script to let the users make a couple of choices, creating the actual command they need to run.

What is a simple way to allow an end user to make a couple of choices to create the command they need to run?

There is 5 server/paths that need to be listed and 5 different files to open, per server/path.

the paths are like this:
\\server1\share\folder\file.day
\\server2\share\folder\file.day
\\server3\share\folder\file.day
\\server4\share\folder\file.day
\\server4\share\folder-2\file.day
file.day is .mon .tue. wed .thu  or .fri

I'd like the user to be able to choose the server\path, then the day,
Something like "Please choose 1. 2. etc, with each server/path listed, total of 5 choices.
Then choose what day it is, 1. monday 2. tuesday, etc.
Creating the command to run, which is (EX: for server1 on tuesday:)

get-filetail -path \\server\share\folder\folder\file.tues -count 1 -wait

thanks!
LVL 2
SquigglyMonkeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason CrawfordTransport NinjaCommented:
How about something like this:

$server = @(
  '\\server1'
  '\\server2'
  '\\server3'
  '\\server4'
  '\\server5'
) | Out-GridView -PassThru

$share = @(
  '\share\folder1'
  '\share\folder2'
  '\share\folder3'
  '\share\folder4'
  '\share\folder5'
) | Out-GridView -PassThru

$file = @(
  '\file.mon'
  '\file.tues'
  '\file.wed'
  '\file.thurs'
  '\file.fri'
) | Out-GridView -PassThru

$result = $server + $share + $file

Get-FileTail -Path $result -Count 1 -Wait

Open in new window

0
SquigglyMonkeyAuthor Commented:
Thankyou, I'll try that, I was about to pst what I was starting to come up with, I found a menu function but wasn't getting very far with it.
function Show-Menu
{
     param (
           [string]$Title = 'Menu1'
     )
     cls
     Write-Host "================ Server-Path ================"
     
     Write-Host "1: Press '1' for Server1."
     Write-Host "2: Press '2' for this option."
     Write-Host "3: Press '3' for this option."
     Write-Host "4: Press '4' for this option."
     Write-Host "5: Press '5' for this option."
	Write-Host "Q: Press 'Q' to quit."
}
do
{
     Show-Menu
     $input = Read-Host "Please make a selection"
     switch ($input)
     {
             '1' {'server1'
                
                
           } '2' {
                
                'You chose option #2'
           } '3' {
                
                'You chose option #3'
           } '4' {
                
                'You chose option #4'
           }
             'q' {test
                return
           }
     }
     pause
}
until ($input -eq 'q')

Open in new window

0
Jason CrawfordTransport NinjaCommented:
Yea that Out-GridView -PassThru is just as good as a Windows Form.  Try it out.
0
Webinar: Miercom Evaluates Wi-Fi Security

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom how WatchGuard's Wi-Fi security stacks up against the competition in our upcoming webinar!

SquigglyMonkeyAuthor Commented:
Do I need to run this some way other than to copy your code into a ps1 file and run that file from within powershell?
When I do, nothing 'prompts' or 'pops up'.
0
Jason CrawfordTransport NinjaCommented:
Doh you must be running version 2.0.  I forgot the #requires statement:

#requires -version 3.0
$server = @(
  '\\server1'
  '\\server2'
  '\\server3'
  '\\server4'
  '\\server5'
) | Out-GridView -PassThru

$share = @(
  '\share\folder1'
  '\share\folder2'
  '\share\folder3'
  '\share\folder4'
  '\share\folder5'
) | Out-GridView -PassThru

$file = @(
  '\file.mon'
  '\file.tues'
  '\file.wed'
  '\file.thurs'
  '\file.fri'
) | Out-GridView -PassThru

$result = $server + $share + $file
Get-FileTail -Path $result -Count 1 -Wait

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason CrawfordTransport NinjaCommented:
You can determine the PowerShell version by running this: $PSVersionTable.psversion
0
SquigglyMonkeyAuthor Commented:
Derp.... Ver 4, but needed to be 'run as admin'.
Works good, is there a way to reduce the real-estate that out-grid is taking up?
0
SquigglyMonkeyAuthor Commented:
Thanks much for this.
0
Jason CrawfordTransport NinjaCommented:
Glad I could help.  Take care :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.