Have been trying to write a script to rename computer with a set prefix and suffix with prompt for the user to enter a 3-6 digit number in between but seem to be struggling. I have tried various methods and I think this is the correct one but it does not seem to change. If I run each line manually it works but not if I run the script? Has to be something simple I am missing but I am struggling to notice what it is. I have commented all the extra code out currently to just run the 3 lines but no change. Any help would be greatly appreciated.
Write-Host
Write-Host "PC renaming"
Write-Host
Write-Host -ForegroundColor Red "NOTE: Your computer will automatically
reboot once complete"
Write-Host
$shutdowntime = 10
$pcname = Read-Host -Prompt 'Input the new PC name'
$newname = 'KBOXFD5'+ $pcname + 'PC'
Rename-Computer -NewName $newname
Write-Host
Write-Host "The device will rebooted in $shutdowntime seconds..."