Reputation: 3
Running a workflow which renames and restarts the computer results in an error.
I had to put in screenshots because I somehow could post the code in here.
Upvotes: 0
Views: 55
Reputation: 124
is this what you're looking for?
$newName = "New name"
$computer = $env:COMPUTERNAME
Rename-Computer -ComputerName $computer -NewName $newName -Restart
Write-Host "Computer name changed to $newName. Rebooting now."
I mean, this isn't a modified version of your code but it does what it seems to be what you asked for:
Rename and reboot the computer
Please let me know if it's what you're after.
Upvotes: 0