So, you were installing Windows Server 2008 R2 and when it came to choosing an edition you went with the Server Core, that minimalistic installation with the reduced attack surface was tempting. Now you’re sitting there staring at a command prompt asking yourself what the heck you were thinking. Don’t abort right away! give Server Core a chance. When I first started experimenting with Server Core my Windows CLI knowledge was seriously lacking, sure I use command line tools all the time (like telnet, netstat, ipconfig and other common utilities) but for the actual configuration of the system that’s another story, last time I used CLI for serious stuff in Windows was probably in Windows Server 2000 and that’s a long time ago. So I started reading a bit about Server Core and how to do basic things using only the Command Line Interface and so far everything is working out ok. So to help others who have stumbled onto Server Core here’s how to do some basic things in Server Core.
Probably one of the most common operations ever carried out after a fresh install is creating a new user.
net user [username] /add *
And it’s always good to know how to change a user password.
net user [username] *
And in case you made a typo creating the new user you can always rename a user account with this command.
wmic UserAccount where Name="[User to be renamed]" call Rename Name="[new username]"
And you most likely want to add a user to the Administrators group at some point in time, if you want to add a user to another group simply change the “Administrators” to the desired group name.
net localgroup Administrators /add [domain]\[username]
If you need to add a user to a group you will probably at some point want to remove a user from a group as well.
net localgroup Administrators /delete [domain]\[username]
In case you don’t want the computer to be called WIN-GARBLEDLETTERSANDSTUFF then you need to invoke this to rename the computer to something more sensible. To confirm the new computer name you can either Reboot or use the command “Set“. Also if you want to view the current name you use the command “hostname”
netdom renamecomputer . /NewName:[new computer name]
Since you’ll be using the command line to do almost everything, including network configuration, it’s not a bad idea to rename the “Local Area Connection” network (default network name) to something more command line friendly like lan (or lan0-x if you have many network adapters). This is done with the netsh utility.
netsh int set interface name="Local Area Connection" newname="lan0"
Now we can save ourselves alot of typing. Next thing we’d probably want to configure is the computer IP, Subnet and Gateway. Again we use the netsh utility. Most netsh commands can be shortened, like for this example you can also use “Netsh int ipv4 set address [network name] static [our ip] [our mask] [our gateway]” but I prefer the following format for clarity.
netsh interface ipv4 set address name="[network name]" source=static address=[our ip] mask=[our mask] gateway=[our gateway]
Next on the menu is setting the DNS Servers, and you might have guessed it but again we use netsh.
netsh interface ipv4 set dns name="[network name]" source=static address=[primary DNS IP address] primary
It’s usually a good practice to have more than one DNS server for redundancy in case the primary fails, to add a secondary DNS server we use a similar command. Also if you want further redundancy you can use the same command to add tertiary and quaternary dns servers by changing the index to 3 and 4.
netsh interface ipv4 add dnsserver name="[network name]" address=[Secondary DNS IP address] index=2
Server core supports Remote Desktop like the other versions of Windows so if you want to enable Remote Desktop you can use this
cscript scregedit.wsf /AR 0
And if you want to disable it you use
cscript scregedit.wsf /AR 1
Also here are some common Windows Update commands, this one sets Windows Updates to Automatic.
cscript scregedit.wsf /AU /4
And this one disables automatic updates.
cscript scregedit.wsf /AU /1
And if you want to view the current Automatic Update settings then
cscript scregedit.wsf /AU /V
If you want to download and install the Windows Update manually the best way I’ve found is to get a “simple” VB script from msdn to search for new updates and install them, you can get it from here (http://msdn.microsoft.com/en-us/library/aa387102%28VS.85%29.aspx) and save it as WUA_SearchDownloadInstall.vbs in the system32 folder (so it will be accessible from anywhere on the system as system32 is in the %path%) then to run it and install the updates.
Every now and again you might need to Reboot the machine.
shutdown /r /t 0 /f /c "[reason for reboot]"
or shut down the machine.
shutdown /s /t 0 /f /c "[reason for shutdown]"
or Log out of the current user
If you don’t have a KMS server to handle activation of new servers then you most likely need to set a new License Key, for that we use slmgr. After running the command we wait for a confirmation message (“Installed product key xxxxx-xxxxx-xxxxx-xxxxx-xxxxx sucessfully”) or an error message if the key is invalid.
slmgr -ipk [xxxxx-xxxxx-xxxxx-xxxxx-xxxxx]
And then we need to Activate Windows, after running the command we need to wait for confirmation of successful activation (or an error message if it fails)
That’s it for the most basic things I can think of, next post about Server Core will probably be about more practical matters like how to remote administer a Server Core installation and adding services and roles.
Jóhannes H. Laxdal is a specialized humanoid carbon unit whose field is computers and telling lousy jokes, it has a tendency to put "well" before every sentence it utters. In here you will find its ramblings about computer-related stuff.
Tags.net 7 8 2008 2008 R2 Administrator Administrator for web ADSI Application Pool AppPool asp.net backup BannerBitmap C# CentOS CIDR Create debian Decimal Dedicated Server Enumerate Enumerate Websites error IE 7 IIS IIS 6 install banner L4D2 Left 4 dead 2 Linux PeriodicRestartSchedule php Recycle Recycling Samba script spam Submask user-agent Website windows Windows 7 Windows 2008 R2 Windows Media Services WMS