Home > Windows Server 2008 > Windows Server 2008 Core – Useful Commands

Windows Server 2008 Core – Useful Commands

Wednesday, September 24, 2008 Leave a comment Go to comments

I’ve found myself using Windows Server 2008 Core quite a lot recently, and apart from using the GUI CoreConfigurator I’ve realised that I’m often completely forgetting a whole bunch of commands related to Server Core setup. Now nine times out of ten I’m working from a prepared Sysprep image with Group Policies setting everything I need; but every so often I forget or am setting up a test lab and need these commands. Anyways, here’s a list of codes that I use very often.

Updated: rearranged code as joining a domain switches the Windows Firewall profile; all firewall changes will be discarded if you make them before joining the domain. Found that out the hard way =)

'Give the computer a sensible name
netdom RenameComputer <hostname> /NewName <new_hostname>

'Then reboot for it to take effect
shutdown /r /t 0

'List network interfaces currently connected
netsh interface show interface

'Set up static primary IP address if needed
netsh interface ipv4 set address “Local Area Connection” static <IP address> <Subnet Mask> <Default Gateway>
netsh interface ipv4 set dnsserver “Local Area Connection” static <DNS IP Address 1> primary
netsh interface ipv4 add dnsserver “Local Area Connection” <DNS IP Address 2> index=2

'If you're in a cluster, tell the cluster NIC not to register itself in DNS
netsh interface ipv4 set dnsserver <Cluster NIC> static none none

'Join our server to our domain
netdom join <hostname> /domain:<full DNS domain name> /userd:<user with rights to add to domain> /passwordd: *

'...and reboot once again
shutdown /r /t 0

'Open firewall ports for remote administration
netsh advfirewall firewall set rule group="Remote Administration" new enable=yes
netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes
netsh advfirewall firewall set rule group="Remote Volume Management" new enable=yes
'Note this last command has to be run on both the Core installation
'And the server/workstation managing it

'And allow ICMP Echo for all firewall profiles
netsh firewall set icmpsetting 8 enable all

'Enable remote connection to the Virtual Disk service
sc config vds start=auto
net start vds

'Let's enable Terminal Services so we can sit at our desk rather than in a server room
cscript c:\windows\system32\SCregEdit.wsf /ar 0

'Reboot the server to make sure this takes effect - may not be necessary here
shutdown /r /t 0

'Confirm regional settings
control timedate.cpl
control intl.cpl

'Turn off Windows Update auto update
cscript SCregEdit.wsf /AU 1
Net stop wuauserv

'Enable WinRM
WinRM quickconfig

'Install your Roles
'More info http://technet.microsoft.com/en-us/library/cc753802.aspx
start /w ocsetup <your role here>

'Download the script from
'http://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx
'Save as C:\WUA_SearchDownloadInstall.vbs and run it to update the server
cscript C:\WUA_SearchDownloadInstall.vbs

'Restart after updates
shutdown /r /t 0

'Whack in your product key and license your server
start /w slmgr.vbs -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
start /w slmgr.vbs -ato

'Just to check it's actually taken effect...
start /w slmgr.vbs -dli

'Log off and your server is in production!
logoff

This is enough to put your server into production and manage it comfortably from your desk, rather than the server room.

Advertisement
Tags:
  1. AndyC
    Tuesday, November 18, 2008 at 6:33 pm | #1

    Ooh, handy bunch of commands there. One little tippet though, when renaming the computer use:

    netdom RenameComputer %computername% /NewName

    And that way you don’t even have to waste time figuring out what random name Windows has decided upon for your Server Core install!

  2. Robert
    Tuesday, June 9, 2009 at 6:14 pm | #2

    I just stumbled across this. Excellent!! Well done, friend!

  3. ZakP
    Tuesday, April 12, 2011 at 6:54 pm | #3

    Brilliant post ….. Thanks a lot!

    I also found that you can use “sconfig” in 2008 R2 Core’s command prompt ….. this opens a menu that has a few basic handy commands.

  4. ja
    Saturday, April 23, 2011 at 11:37 am | #4

    extra credit question – when I use remote desktop connection to a server core, I often x out of the command prompt dialogue box. Ooooops. Now all I have is a blank screen. How do you open uo the command dialogue box?

  5. Jesse
    Wednesday, June 22, 2011 at 7:57 pm | #5

    If you close out the command line box, you can bring up the Task Manager by hitting Ctrl-Alt-End and clicking Start Task Manager.

    From there, go to File -> New Task and type in CMD.

    Do I get a cookie?

  6. Volverin Aaryan
    Thursday, November 10, 2011 at 10:18 am | #6

    Awesome one dude.. I had been using linux and windows was the thing not a piece of cake for me in the initial stages… but found out your blog… Man its very impressive, really appreciate your work nad cheers to the efforts you made for arranging the commands.. thanks…

  1. Thursday, February 24, 2011 at 11:50 am | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s