Blog Post

Rename a Server with PowerShell

,

I’m sure many people are experimenting with VMs and SQL Server. If you’re like me, many of you just default to installing Windows 7/10 or Windows Server xx Standard for your testing. Those systems work fine, but I’ve been trying to build slimmer systems, which means looking at Server Core. Installing Server Core is much the same as other versions, though you end up with only a command line. If you’re like me, using VMWare, you also might end up with a server name like “WIN-LKR3R4FfL5T”.

I want to change that. It’s a fine name if I’m working locally. It’s not to much fun connecting across a network. This post looks at how to rename that machine.

Get the Name

The first thing is to get the name. I’ve always just right clicked the Computer in Explorer, but that’s not possible in Core. Instead, I decided to use PowerShell, since I know how to do that.

First, start PowerShell, which is simple.

2016-10-02 12_39_57-SQL2016Alone - VMware Workstation

Next, use the environment variable, $env:computername, to find the name. You can see me do that here:

2016-10-02 12_42_20-SQL2016Alone - VMware Workstation

Rename-Computer

Technically I don’t need the name to rename the system, but I wanted to know what it was. Plus, I’ll want to verify things work. There is a cmdlet, Rename-Computer, that does exactly what you’d expect. It renames a machine.

There are various parameters, but the only one I really need is “NewName”. I haven’t joined a domain yet, so no reason to worry about that security. I could include the Restart parameter, but I wanted the screenshot below.

2016-10-02 12_45_09-SQL2016Alone - VMware Workstation

That’s really it, other than a restart. Intuitively enough, Restart-Computer works fine.

And on restart, I log in and can see my rename worked fine.

2016-10-02 12_48_37-SQL2016Alone - VMware Workstation

Now, on to SQL Server installation.

Filed under: Blog Tagged: powershell, syndicated, windows

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating