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.

2
  • Could you not just use Read-Host before the loops? Not a "popup" but the result is the same. Commented Sep 27, 2016 at 16:15
  • stackoverflow.com/questions/8184167/… Commented Sep 27, 2016 at 16:17

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.