cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Windows domain PC Name

DaveDischord
Engaged Sweeper II
New Action for PCs

Action line:
powershell.exe "{actionpath}ChangePCName.ps1" {smartname}

ChangePCName.ps1: (Make sure Encoding is right, like UCS2_LE or something, and of course, save in your action path)

param([String]$oldname)
$newname=Read-Host -Prompt "Input new Name and click [Enter]"

Rename-computer –computername $oldname –newname "$newname" –domaincredential [domainname]\administrator -force -restart


It'll come up with a shell asking for the new name you want it to be, then ask for your administrator password, or whatever user has rights to change the PC name, then that PC will restart.

4 REPLIES 4

max204
Engaged Sweeper II
Great, thank you!

There's one thing you must change on your local computer that you're running Lansweeper from and that is to open PowerShell as an administrator and run this command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Otherwise it won't run the action from the web browser on your PC.

crashff
Champion Sweeper
max204 wrote:
Great, thank you!

There's one thing you must change on your local computer that you're running Lansweeper from and that is to open PowerShell as an administrator and run this command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Otherwise it won't run the action from the web browser on your PC.


Does this run on the machine hosting Lansweeper, or where I am accessing the website from? Local Computer and "location where Lansweeper is running" are not always the same.

max204 wrote:

Does this run on the machine hosting Lansweeper, or where I am accessing the website from? Local Computer and "location where Lansweeper is running" are not always the same.


That's a good question. I'm running everything on localhost, so I'm not too sure where the commands are initiated from. I'm going to go with a logical guess and say its from the server hosting LanSweeper, since its back-end functionality. Please correct me if I'm wrong. I'm curious myself.

CyberCitizen
Honored Sweeper
Word of warning don't do on machines connected via Wifi if using a WiFi certificate as it will need to download an updated cert with new name etc.