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?
The code block above seems to work, yet I'm encountering the issue below: