1

So i have this powershell...

pushd "C:\PSF\Move to V6\DTT Files"
$configFiles = Get-ChildItem . *.dtt -rec
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "OLD", "NEW" } |
Set-Content $file.PSPath
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "OLD2", "NEW2" } |
Set-Content $file.PSPath
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "OLD3", "NEW3" } |
Set-Content $file.PSPath
}

What i am hoping to do is have it pop up with a few boxes asking what you want: New, New2 and New3 to be specificly.

I am very new to powershell so i am clueless when it comes to doing something like that. (Or even if you can)

If it's not possible, i will accept suggestions for other things i can do in place of doing this.

Steve101
  • 51
  • 1
  • 8
  • Could you not just use `Read-Host` before the loops? Not a "popup" but the result is the same. – Matt Sep 27 '16 at 16:15
  • http://stackoverflow.com/questions/8184167/prompt-for-user-input-in-powershell – Matt Sep 27 '16 at 16:17

1 Answers1

0

If you're using PowerShell v3+ then I like using Out-GridView for this purpose:

$choices = @('NEW', 'NEW2', 'NEW3')

$selection = $choices | Out-GridView -Title 'Select Replacement' -OutputMode Single

It's simple, effective, intuitive, and built-in.

briantist
  • 45,546
  • 6
  • 82
  • 127