Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Windows Server 2012 : Managing networking using Windows PowerShell (part 2) - Examples of network-administration tasks

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
5/18/2014 9:51:53 PM

Examples of network-administration tasks

The best way to learn how to use Windows PowerShell to administer network settings and services on Windows Server 2012 is to experiment with performing different tasks in a test environment.

Note

Importance of learning Windows PowerShell

Windows Server 2012 provides businesses with a foundation they can use for building private and public clouds. If doing this is part of your job as an administrator, you really need to become efficient at using Windows PowerShell. That’s because the cloud requires automation in order to function as intended, and Windows PowerShell is Microsoft’s platform for automating server-administration tasks.

Display network adapters with 100-Mbps link speed

You can use the Get-NetAdapter cmdlet to display all network adapters on the server that have a link speed of 100 megabits per second (Mbps) like this:

PS C:\> Get-NetAdapter | Where-Object -FilterScript {$_.LinkSpeed -eq "100 Mbps"}

Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
Ethernet 2 Broadcom NetXtreme Gig... 13 Up A4-BA-DB-0A-96-0C 100 Mbps
Ethernet Broadcom NetXtreme Gig... 12 Up A4-BA-DB-0A-96-0B 100 Mbps

The output of this command consists of objects that can be passed through the pipeline to other cmdlets. For example, you could pipe the output into the Set-NetIPInterface cmdlet to assign a metric value of 5 to all interfaces having a link speed of 100 Mbps as follows:

PS C:\> Get-NetAdapter | Where-Object -FilterScript {$_.LinkSpeed -eq "100 Mbps"} | `
Set-NetIPInterface -InterfaceMetric 5

Disable a binding on a network adapter

You can enable and disable bindings on a network adapter using Windows PowerShell. For example, start by using the Get-NetAdapterBinding cmdlet to display the bindings for the specified interface:

PS C:\> Get-NetAdapterBinding -InterfaceAlias "Ethernet 2"

Name DisplayName ComponentID Enabled
---- ----------- ----------- -------
Ethernet 2 Hyper-V Extensible Virtual Switch vms_pp False
Ethernet 2 Link-Layer Topology Discovery Responder ms_rspndr True
Ethernet 2 Link-Layer Topology Discovery Mapper I/O Driver ms_lltdio True
Ethernet 2 Microsoft Network Adapter Multiplexor Protocol ms_implat False
Ethernet 2 Client for Microsoft Networks ms_msclient True
Ethernet 2 Windows Network Virtualization Filter driver ms_netwnv False
Ethernet 2 QoS Packet Scheduler ms_pacer True
Ethernet 2 File and Printer Sharing for Microsoft Networks ms_server True
Ethernet 2 Internet Protocol Version 6 (TCP/IPv6) ms_tcpip6 True
Ethernet 2 Internet Protocol Version 4 (TCP/IPv4) ms_tcpip True

To disable a specific binding such as QoS Packet Scheduler, you can use the DisableNetAdapterBinding cmdlet like this:

PS C:\> Disable-NetAdapterBinding -Name "Ethernet 2" -ComponentID ms_pacer

You can use the Enable-NetAdapterBinding cmdlet to re-enable the binding.

Disable a network adapter

You can disable a specific network adapter or even all network adapters using Windows PowerShell. For example, the following command disables the adapter named “Ethernet 2” with no confirmation prompt displayed:

PS C:\> Disable-NetAdapter -Name "Ethernet 2" -Confirm:$false

To disable all network adapters on the server, you can use this command:

PS C:\> Disable-NetAdapter -Name *

Note that all remote connectivity with the server will be lost if you do this.

To enable any network adapters that are disabled, you can use the Enable-NetAdapter cmdlet.

Creating a DHCP server scope

You can manage Windows Server 2012 DHCP servers using Windows PowerShell. Common DHCP server-management tasks include creating scopes, creating exclusion ranges, creating reservations, configuring scope and server options, and so on.

For example, let’s begin by viewing all the scopes currently configured on the DHCP server:

PS C:\> Get-DhcpServerv4Scope

ScopeId SubnetMask Name State StartRange EndRange LeaseDuration
------- ---------- ---- ----- ---------- -------- -------------
172.16.11.0 255.255.255.0 test Active 172.16.11.35 172.16.11.39 8.00:00:00

Note that there is currently only one active scope on the DHCP server. Now add a second scope for the IP address range 172.16.12.50 through 172.16.12.100. Leave the scope inactive until you finish configuring exclusions and reservations for it:

PS C:\> Add-DhcpServerv4Scope -EndRange 172.16.12.100 -Name test2 `
-StartRange 172.16.12.50 -SubnetMask 255.255.255.0 -State InActive

Note that in this cmdlet it doesn’t matter what order you specify the parameters in because you specified the end of the address range before specifying its beginning.

Running Get-DdhpServerv4Scope again indicates that adding the new scope was successful:

PS C:\> Get-DhcpServerv4Scope

ScopeId SubnetMask Name State StartRange EndRange LeaseDuration
------- ---------- ---- ----- ---------- -------- -------------
172.16.11.0 255.255.255.0 test Active 172.16.11.35 172.16.11.39 8.00:00:00
172.16.12.0 255.255.255.0 test2 Inactive 172.16.12.50 172.16.12.100 8.00:00:00

Now exclude the range 172.16.12.70 through 172.16.12.75 from the new scope:

PS C:\> Add-DhcpServerv4ExclusionRange -EndRange 172.16.12.75 -ScopeId 172.16.12.0 `
-StartRange 172.16.12.70

Let’s also add a reservation for a file server:

PS C:\> Add-DhcpServerv4Reservation -ClientId EE-05-B0-DA-04-00 -IPAddress 172.16.12.88
`

-ScopeId 172.16.12.0 -Description "Reservation for file server"

Here EE-05-B0-DA-04-00 represents the MAC address of the file server’s network adapter.

Let’s also configure a default gateway address for the new scope by creating a scope option as follows:

PS C:\> Set-DhcpServerv4OptionValue -Router 172.16.12.1 -ScopeId 172.16.12.0

If you want to create a server option instead of a scope option, you could do this by omitting the –ScopeID parameter from the preceding command.

Now you’re done creating and configuring the new scope, so let’s finish by activating it:

PS C:\> Set-DhcpServerv4Scope -StateActive

Note

Why doesn’t Get-Command display the expected results?

If you run the command Get-Command *dhcp* on a clean install of Windows Server 2012, you won’t get any results. That’s because Get-Command can display commands only for Windows PowerShell modules that are installed on the server, and the module for DHCP isn’t installed until you add the DHCP Server role to your server.

Creating DNS resource records

You can manage Windows Server 2012 DNS servers using Windows PowerShell. Common DNS server-management tasks include adding resource records to zones, configuring forwarders, configuring root hints, and so on.

For example, let’s view a list of zones on a DNS server that is also a domain controller for the corp.contoso.com domain:

PS C:\> Get-DnsServerZone

ZoneName ZoneType IsAutoCreated IsDsIntegrated IsRever... IsSigned
-------- -------- ------------- -------------- ------- --------
_msdcs.corp.contoso.com Primary False True False True
0.in-addr.arpa Primary True False True False
127.in-addr.arpa Primary True False True False
255.in-addr.arpa Primary True False True False
corp.contoso.com Primary False True False False
TrustAnchors Primary False True False False

To view a list of resource records of type A (address) in the corp.contoso.com zone, you can pipe the output of the Get-DnsServerResourceRecord cmdlet into the Where-Object cmdlet like this:

PS C:\> Get-DnsServerResourceRecord -ZoneName corp.contoso.com | Where-Object
{$_.RecordType -eq "A"}

HostName RecordType Timestamp TimeToLive RecordData
-------- ---------- --------- ---------- ----------
@ A 7/8/2012 12:00:00 PM 00:10:00 172.16.11.36
@ A 7/8/2012 1:00:00 PM 00:10:00 172.16.11.232
DomainDnsZones A 7/8/2012 12:00:00 PM 00:10:00 172.16.11.36
DomainDnsZones A 7/8/2012 12:00:00 PM 00:10:00 172.16.11.232
ForestDnsZones A 7/8/2012 12:00:00 PM 00:10:00 172.16.11.36
ForestDnsZones A 7/8/2012 12:00:00 PM 00:10:00 172.16.11.232
sea-srv-1 A 0 01:00:00 172.16.11.232
SEA-SRV-5 A 0 01:00:00 172.16.11.36

To add a new A resource record for a test server, you can use the Add-DnsServerResourceRecordA cmdlet like this:

PS C:\> Add-DnsServerResourceRecordA -IPv4Address 172.16.11.239 -Name SEA-TEST `
-ZoneName corp.contoso.com

You can also add other types of resource records—such as PTR, CN, or MX records—using the preceding cmdlet. And you can use the Remove-DnsServerResourceRecord cmdlet to remove resource records from a zone.

There are over 100 different cmdlets in the DnsServer module for Windows PowerShell in Windows Server 2012. Table 1 shows the cmdlets you can use to perform some common DNS administration tasks.

Table 1. Common DNS server-administration tasks and Windows PowerShell cmdlets you can use to perform them.

TASK

CMDLET

Configure forwarders

Add-DnsServerForwarder

Create a stub zone

Add-DnsServerStubZone

Display the contents of the DNS server cache

Show-DnsServerCache

Clear the DNS server cache

Clear-DnsServerCache

Display full configuration details of the DNS server

Get-DnsServer

Display statistics for the DNS server

Get-DnsServerStatistics

Import root hints

Import-DnsServerRootHint

Configure the DNS server cache settings

Set-DnsServerCache

Configure DNS server scavenging

Set-DnsServerScavenging

Initiate scavenging

Start-DnsServerScavenging

Other -----------------
- Sharepoint 2013 : Managing Site Security - Create Permission Levels for a Site
- Sharepoint 2013 : Managing Site Security - Edit a SharePoint Group’s Settings
- Sharepoint 2013 : Managing Site Security - Create a SharePoint Group for a Site
- Sharepoint 2013 : Assign Users’ Permissions on a Site
- Sharepoint 2013 : Get to a Site’s Permission Management Page (part 2) - Check What Permissions a User or a Group Has on a Site
- Sharepoint 2013 : Get to a Site’s Permission Management Page (part 1)
- Microsoft Exchange Server 2013 : Creating new mailboxes (part 4) - Automating mailbox settings,Ready-to-go custom attributes
- Microsoft Exchange Server 2013 : Creating new mailboxes (part 3) - Default folders, Manipulating mailbox settings
- Microsoft Exchange Server 2013 : Creating new mailboxes (part 2) - Languages
- Microsoft Exchange Server 2013 : Creating new mailboxes (part 1)
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server