# Prompting for a user input to be used on a Powershell command?

I'm trying to execute the code below and it is working:

PS C:\> Rename-Computer -NewName TEST -DomainCredential okadamanila\itservices


Given that hostname is given on the PS1 file - however, I would like to ask or prompt the user for input to substitute the hostname; I've tried using the code block below:

$hostname = read-host "Please enter your name" Write-Host "YOUR PREFERRED HOSTNAME IS$hostname - INITIALIZING HOSTNAME CHANGE"
$credential = Get-Credential PS C:\> Rename-Computer -NewName$name -DomainCredential $credential Read-Host -Prompt "Press Enter to exit"  Where the input from the user would be the hostname that'll be used on the Rename-Computer function, it this possible? EDIT: The code block above seems to work, yet I'm encountering the issue below: ERROR BEING ENCOUNTERED • What exactly is going wrong? If I do: $var = read-host "Question: " followed by $var I get inside$var what I entered at the question. – LPChip Sep 8 '17 at 10:49