PowerShell Snippets: Prompt for Multiple Inputs

PowerShellThis post is part of the series on PowerShell Snippets.

Over the last two posts of this series, I’ve shown PowerShell cmdlets which prompt for user input and prompt for secure entry of passwords. A PowerShell script can prompt for multiple inputs as well as output text to screen.

When I originally posted about the Write-Output cmdlet, I only showed how it could be used to output text; you can also use a couple of parameters with this command to change the foreground or background colour.

The below script example, shows two outputs to screen using these parameters as well as prompting the user to input two pieces of data:

Write-Host "Please enter details of the plugin release" -ForegroundColor Green

$ghRepository = Read-Host "Please enter the repository name"

$ghTag = Read-Host "Please enter the tag"

Write-Host "$ghRepository $ghTag will be released." -ForegroundColor Yellow -BackgroundColor Black