get value from user

$minLon = Read-Host “Please enter minLon”

$minLat = Read-Host “Please enter minLat”

$maxLon = Read-Host “Please enter maxLon”

$maxLat = Read-Host “Pleaes enter maxLat”

Hi everyone. I am new in poershell and i wrote this code with your help and it works very good but now i want get values from user with window (like pop window then user can enter values) how can i modify this code please give me tips. Thanks very much.

$url = ‘[bbox= {0},{1},{2},{3}][natural=tree][@meta]’ -f $minLon,$minLat,$maxLon,$maxLat

$output = “C:\Users\alo\Desktop\Montreal.osm”
$start_time = Get-Date

Invoke-WebRequest -Uri $url -OutFile $output
Write-Output “Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)”

PowerShell itself doesn’t have any native “pop up” for gathering information; it’s a command-line shell, not a graphical development environment. You can certainly use .NET to create a GUI, but it’s not just a simple line of code. SAPIEN’s PowerShell Studio product might be an easy way to get into GUI programming if you’ve not done it before, but I’ll caution you that it’s a BIG space.

You could alternately use the VisualBasic InputBox method for something quick and dirty; Google “PowerShell InputBox” and you’ll find several examples.

Another option is a WPF GUI:

When you are getting input, especially from Read-Host, you can get into a rabbit hole. Enter a color and put 10, then you start adding code to validation and you have a complex script with loops. GUI’s are built to do validation and enter data, so if you have to get data then a form is your best bet. As Don suggested, you can use Sapien’s tool, but if you aren’t building a lot of forms I would go the cheap route and leverage a combination of Visual Studio and Powershell.

To get you started with a GUI you could check out


Take a look at this module:

Thanks all very much for tips