13 Jan 2015
Sometimes we may require to get some information from the end user during the execution of our PowerShell Scripts. i.e., I faced this one to get the Service Account Name and Password. As it contains some Password, we may not be able to write it on the Config file. To achieve that, let us see the below commands.
$ServiceAccountName = Read-Host "Please enter the Service Account Name "
No need to add a colon at the end of the prompt (e.g., “Please enter the Service Account Name:”); Windows PowerShell will add the colon to the end of the prompt for you.
Within the Windows PowerShell console, that looks like this:
To ask for the Password columns,
$ServiceAccountName = Read-Host "Please enter the Password " –assecurestring