In this document you will find common commands to administer Windows Server 2008 by command shell.
Network Management
Get index number of the network adapter | netsh interface ipv4 show interfaces |
Change to a static IP address | netsh interface ipv4 set address name=”<ID>” source=static address=<StaticIP> mask=<SubnetMask> gateway=<DefaultGateway> |
Set DNS | netsh interface ipv4 add dnsserver name=”<ID>” address=<DNSIP> index=1 |
Set Secondary DNS | netsh interface ipv4 add dnsserver “Local Area Connection” address=<IP address of the secondary DNS server> index=2 Register=None |
Verify IP Configuration | Ipconfig /all |
Change the name of the network interface | Netsh int set interface name = “Local Area Connection” newname = “LAN” |
Setting the network interface to DHCP | Netsh int ipv4 set address “Local Area Connection” source=dhcp |
Setting the primary DNS server | Netsh int ipv4 set dnsserver “Local Area Connection” static 192.168.1.200 primary |
Change to a DHCP-provided IP address from a static IP address. | netsh interface ipv4 set address name=<IP address of local system> source=DHCP |
Configure your server to use a proxy server. | netsh Winhttp set proxy <servername>:<portNote Server Core installations cannot access the Internet through a proxy that requires a password to allow connections. |
PowerShell command to disable IPv6 | New-ItemProperty -Path HKLM:SYSTEMCurrentControlSetservicesTCPIP6Parameters -Name DisabledComponents -PropertyType DWord -Value 0xffffffff |
Basic Config
Activate Windows |
Cscript c:windowssystem32slmgr.vbs –ato |
Rename the Server Core computer |
Netdom renamecomputer %computername% /NewName:new-name /UserD:domain-username /PasswordD:* |
Joining a domain |
netdom add newcomputername> /domain:<domainname> /userd:Administrator /passwordd:* |
Removing from a domain |
netdom remove |
Reset the administrator password |
Net use administrator * |
Add a user to the local Administrators group |
net localgroup Administrators /add <domain><username> |
Remove a user from the local Administrators group |
net localgroup Administrators /delete <domainusername> |
Add a user to the local computer |
net user <domainuser name> /add * |
Add a group to the local computer |
net localgroup <group name> /add |
Remote Management
Disable Windows Firewall | netsh advfirewall set allprofiles state off |
Manage Firewall | Netsh firewall set opmode enableNetsh firewall set opmode disable |
Enable Remote Administration | Netsh firewall set service remoteadmin enable |
To use the Disk Management MMC snap-in remotely | Net start vds |
Enable remote administration of the firewall. | netsh advfirewall firewall set rule group=”Windows Firewall Remote Management” new enable=yes |
Services and processes
List the running services. | sc query |
Start a service. | sc start <service name> net start <service name> |
Stop a service. | sc stop <service name> net stop <service name> |
Retrieve a list of running applications and associated processes. | tasklist |
Stop a process forcibly. | taskkill /PID <process ID> |