Monday, October 21, 2013

Windows Server core 2008 R2 Commands

Hostname, domain membership:
Rename computer
netdom renamecomputer %computername% /newname:MyNewHostname
Join machine to domain
netdom join %computername% /domain:corp.mycompany.com/userd:CORP\jsmith /passwordd:*
Rename computer while joined to domain
netdom renamecomputer %computername% /newname:MyNewHostname/userd:CORP\jsmith /passwordd:*
Remove machine from domain
netdom remove %computername%
Interfaces and addresses:
View the current interface list
netsh interface show interface
Set static IP, mask, gateway
netsh interface ipv4 set address ”Local Area Connection”source=static 10.3.1.11 255.255.255.0 10.3.1.1
Set primary DNS server
netsh interface ipv4 add dnsserver ”Local Area Connection”address=10.3.1.21 index=1
Set secondary DNS server
netsh interface ipv4 add dnsserver ”Local Area Connection”address=10.3.1.22 index=2
Remove DNS server from interface
netsh interface ipv4 delete dnsservers ”Local Area Connection”10.3.1.21 (or all)
Set interface to DHCP
netsh interface ipv4 set address ”Local Area Connection”source=dhcp
Disable interface
netsh interface set interface “Local Area Connection” disabled (orenabled to re-enable)


Drivers and services:
Query active drivers
sc query type= driver
Install a driver
pnputil -i -a oemdriver.inf
List running services
sc query
Start / stop a service
sc start (service name) sc stop (service name)
Disable a service
sc config (service name) start= disabled


Windows Firewall, remote management:
Allow server to be managed by Remote Desktop
cscript C:\Windows\System32\SCregEdit.wsf /ar 0
Verify registry entry for above
cscript C:\Windows\System32\SCregEdit.wsf /ar v
Allow Remote Desktop sessions from older RDP clients (lower security setting)
cscript C:\Windows\System32\SCregEdit.wsf /cs 0
Verify registry entry for above
cscript C:\Windows\System32\Scregedit.wsf /cs v
Windows Firewall: allow ICMPv4 echo-request inbound
netsh advfirewall firewall add rule name=”ICMP Allow incoming V4 echo request” protocol=icmpv4:8,any dir=in action=allow
Windows Firewall: allow Remote Desktop
netsh advfirewall firewall set rule group=”Remote Desktop” new enable=yes
Windows Firewall: allow remote management of Windows Firewall
netsh advfirewall firewall set rule group=”Windows Firewall Remote Management” new enable=yes
Windows Firewall: allow remote management of OS via MMC snap-ins
netsh advfirewall firewall set rule group=”Remote Administration” new enable=yes
Enable Windows Remote Shell
WinRM quickconfig


Power management:
List existing Power Schemes
powercfg -l
Turn hibernation off
powercfg -hibernate OFF
Set absentia power scheme (used when no one is logged in)
powercfg -setabsentia 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Set Power Configuration for High Performance
powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c


Other:
Install OS product key
slmgr.vbs -ipk 1234-5678-90ab-cdef-ghij
Activate OS installation
slmgr.vbs -ato
List processes
tasklist
Kill process by process ID
taskkill /PID 3852
Invoke Task Manager
taskmgr
List log names
wevtutil el
Export log to file
wevtutil epl c:\mylog1.txt
Query log for events
wevtutil qe /f:text System
Clear log
wevtutil cl System
Adjust paging file
wmic pagefileset where name=”d:\pagefile.sys” set InitialSize=1024,MaximumSize=2048
Set proxy setting
netsh winhttp set proxymyproxy.corp.mycompany.com:8080
Add domain account to local Administrators group
net localgroup Administrators /add CORP\jsmith
Delete domain account from local Administrators group
net localgroup Administrators /delete CORP\jsmith
Reboot the machine immediately
shutdown /r /f /t 0
Log off current interactive session
logoff


View installed roles: Dism /online /get-features /format:table
Active Directory Certificate Services
Dism /online /enable-feature /featurename:CertificateServicesUninstall: Dism /online /disable-feature /featurename:CertificateServices
Active Directory Lightweight Directory Services
Dism /online /enable-feature /featurename:DirectoryServices-ADAM-ServerCore Uninstall: Dism /online /disable-feature /featurename:DirectoryServices-ADAM-ServerCore
Active Directory Domain Services
dcpromo /unattend:myunattend.txt  Demote: dcpromo
DNS Server
Dism /online /enable-feature /featurename:DNS-Server-Core-RoleManage: dnscmd Uninstall: Dism /online /disable-feature /featurename:DNS-Server-Core-Role
DHCP Server
Dism /online /enable-feature /featurename:DHCPServerCore Manage: netsh sc config dhcpserver start= auto net start dhcpserver Uninstall: Dism /online /disable-feature /featurename:DHCPServerCore
File Services
Dism /online /enable-feature /featurename:FRS-infrastructure Dism /online /enable-feature /featurename:DFSN-Server Dism /online /enable-feature /featurename:DFSN-Server Dism /online /enable-feature /featurename:ServerForNFS-Base Dism /online /enable-feature /featurename:ClientForNFS-Base Uninstall: Dism /online /disable-feature /featurename:(specify role name)
Hyper-V
Dism /online /enable-feature /featurename:Microsoft-Hyper-V
Print Services
Dism /online /enable-feature /featurename:Printing-ServerCore-Role 32-bit support: Dism /online /enable-feature /featurename:Printing-ServerCore-Role-WOW64 Dism /online /enable-feature /featurename:Printing-LPDPrint-Service (manage by using Print Management console from another machine)


View installed features: Dism /online /get-features /format:table
BranchCache
Dism /online /enable-feature /featurename:PeerDistDism /online /enable-feature /featurename:PeerDistHashPDism /online /enable-feature /featurename:SMBHashGeneration
IIS Management Service
Dism /online /enable-feature /featurename:IIS-ManagementServiceEnable remote management:HKLM\Software\Microsoft\WebManagement\Server - changeEnableRemoteManagement to 1; net start wmsvc
Input Method Editor 32-bit support
Dism /online /enable-feature /featurename:ServerCore-EA-IME-WOW64
.NET Framework 2.0
Dism /online /enable-feature /featurename:NetFx2-ServerCore 32-bit support: Dism /online /enable-feature /featurename:NetFx2-ServerCore-WOW64
.NET Framework 3.0 and 3.5
Dism /online /enable-feature /featurename:NetFx3-ServerCore 32-bit support: Dism /online /enable-feature /featurename:NetFx2-ServerCore-WOW64 32-bit support: Dism /online /enable-feature /featurename:NetFx3-ServerCore-WOW64
QWAVE
Dism /online /enable-feature /featurename:QWAVE
Removable Storage
Dism /online /enable-feature /featurename:Microsoft-Windows-RemovableStorageManagementCore
Simple Network Management Protocol (SNMP)
Dism /online /enable-feature /featurename:SNMP-SC
Subsystem for UNIX-based applications
Dism /online /enable-feature /featurename:SUACore 32-bit support: Dism /online /enable-feature /featurename:SUACore-WOW64
Telnet client
Dism /online /enable-feature /featurename:TelnetClient
Windows Internet Name Service (WINS)
Dism /online /enable-feature /featurename:WINS-SC
Windows PowerShell
Dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell32-bit support: Dism /online/enable-feature /featurename:MicrosoftWindowsPowerShell-WOW64
Windows PowerShell Best Practices Analyzer cmdlets
Dism /online /enable-feature /featurename:BestPractices-PSH-Cmdlets
Windows PowerShell Server Manager cmdlets
Dism /online /enable-feature /featurename:ServerManager-PSH-Cmdlets
Windows Server Backup
Dism /online /enable-feature /featurename:WindowsServerBackup
Windows Server Backup Windows PowerShell cmdlets
Dism /online /enable-feature /featurename:WindowsServerBackupCommandlet
Windows Server Migration Tools
Dism /online /enable-feature /featurename:ServerMigration
WoW64
Dism /online /enable-feature /featurename:ServerCore-WOW64(installed by default)


The following may require additional hardware:
BitLocker Drive Encryption
Dism /online /enable-feature /featurename:BitLocker Remote administration tool: Dism /online /enable-feature /featurename: BitLocker-RemoteAdminTool
Failover Clustering
Dism /online /enable-feature /featurename:FailoverCluster-Core (not supported in Standard Edition)
Multipath IO
Dism /online /enable-feature /featurename:MultipathIo
Network Load Balancing
Dism /online /enable-feature /featurename:NetworkLoadBalancingHeadlessServer

Uninstall: Dism /online /disable-feature /featurename:(specify feature name)