Posts Tagged ‘cmd’

CMD line: add domain to local intranet zone

A quick way to add domains to a computers Local intranet zone is to run the following regs in cmd. No Admin rights needed.

REG ADD “HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\ ” /v https /t REG_DWORD /d 1 /f
REG ADD “HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\ ” /v https /t REG_DWORD /d 1 /f

Tags: , ,

Configure DHCP server with cmd or powershell

I wanted to share real quick how you set up and configure a DHCP server on Windows Server 2008 R2 or 2012 (R2) with he command line or powershell.

Windows Server 2008 R2:
Let’s begin with Windows Server 2008 R2, which doesn’t have any dhcp cmdlets in powershell so we have to mostly stick to the commandline.

To install the DHCP role, open an elevated powershell window:
Import-module ServerManager
Add-windowsfeature -Name DHCP

Note that the DHCP Server service is installed but stopped and disabled. Now we have to go to an elevated command prompt for the rest.To set the service to automatic startup and start the service.
sc config dhcpserver start= auto
net start dhcpserver

Authorize the server in AD:
netsh dhcp add server Server1.dhcplab.local

Create a scope, which is empty
netsh dhcp server add scope "Scope1"

Add a range of IP addresses for leasing
netsh dhcp server scope add iprange

Set the default gateway option
netsh dhcp server scope set optionvalue 003 IPADDRESS

Set the lease time in seconds
netsh dhcp server scope set optionvalue 51 DWORD 28800

Set the DNS server
netsh dhcp server scope set optionvalue 006 IPADDRESS

Add a DHCP reservation, for a printer in this case
netsh dhcp server scope add reservedip A1B2C3D4E5F6 "Printer1" "Reservation for Printer1"

Windows Server 2012
Everything in an elevated powershell window. How sweet it is! 🙂

Install the DHCP Role (no need to configure the service afterwards)
add-windowsfeature -Name DHCP -includemanagementtools

Authorize the DHCP server

Add scope with IP range for leasing
Add-DhcpServerv4Scope -Name "Scope2" -StartRange -EndRange -SubnetMask

Set lease duration (days.hours:minutes:seconds)
Set-DhcpServerv4Scope -ScopeId -LeaseDuration 1.00:00:00

Set default gateway
Set-DhcpServerv4OptionValue -ScopeId -Router

Set dns server and domain name
Set-DhcpServerv4OptionValue -DnsServer -DnsDomain dhcplab.local

Set IP reservation, again for a printer
Add-DhcpServerv4Reservation -ScopeId -IPAddress -ClientId A1-B2-C3-D4-E5-F6 -Description "Reservation for Printer1" -Name "Printer1"

SCCM: How to find computer model in commandline

November 26, 2012 Leave a comment

To retrive the Computer model from commandline use the following command:

wmic csproduct get name

This is usefull when you are making model specified driverpacks i System Center Configuration Manager task sequence.

there is several wmic commands that you can use, for example to retrive serial number use this:

wmic bios get serialnumber
Tags: , ,
%d bloggers like this: