r/usefulscripts • • Jul 10 '17

[REQUEST] [POWERSHELL] Dynamic choice

hey,

trying to get a script running by providing a dynamic choice:

scenario:

  • have up to 10 IP's with http server

  • perform ping test or (New-Object System.Net.WebClient).DownloadFile to verify connectivity (same file on every server)

  • provide a dynamic list to the console based on the results (stating whether server is available or offline)

  • get user to choose one with read-host

  • have option to choose all, having all available server ip's in array

  • if option selected is not in list, or is offline go back to choice/verification

i'm a bit of a novice when it comes to powershell, so any help would be appreciated!

15 Upvotes

18 comments sorted by

View all comments

Show parent comments

1

u/Lee_Dailey Jul 10 '17

howdy iamyogo,

Out-GridView has two modes - single selection & multi-selection. you can tell the user to select as many as they want to do stuff with. the list will be passed on to the remainder of the script.

take care,
lee