How To Set DNS Server Address on Nano Server using PowerShell DSC #NanoServer #PowerShell #DSC

Hello folks,

As we are approaching the holidays and being busy preparing for Christmas and New Year! I thought let’s end-up the year with a Nano gift J

In the previous post, I showed you step by step on how to run a Hyper-V Cluster on Nano Server.

In today’s blog post, we will set the DNS server address on all Nano Servers using PowerShell Desired State Configuration.

As you might know, Microsoft added new packages into Nano Server in Windows Server 2016 Technical Preview 4.

At the time of writing this post, here is the list of current packages (roles and features) for your reference:

  • Microsoft-NanoServer-Compute-Package
  • Microsoft-NanoServer-Containers-Package
  • Microsoft-NanoServer-DCB-Package
  • Microsoft-NanoServer-Defender-Package
  • Microsoft-NanoServer-DNS-Package
  • Microsoft-NanoServer-DSC-Package
  • Microsoft-NanoServer-FailoverCluster-Package
  • Microsoft-NanoServer-Guest-Package
  • Microsoft-NanoServer-IIS-Package
  • Microsoft-NanoServer-NPDS-Package
  • Microsoft-NanoServer-OEM-Drivers-Package
  • Microsoft-NanoServer-Storage-Package
  • Microsoft-OneCore-ReverseForwarders-Package
  • Microsoft-Windows-Server-SCVMM-Compute-Package
  • Microsoft-Windows-Server-SCVMM-Package

For the purpose of this demo, all you need to do is:

1. Mount the ISO of Windows Server 2016 TP4 installation media.
2. Change to “NanoServer” directory on the TP4 installation media.
3. Import NanoServerImageGenerator.psm1 module.
4. Create Nano image that contains DSC package (you can add other roles if you need to).
5. Create NanoServer Virtual Machines.
6. Download and import xNetworking PowerShell DSC Module.
7. Push the DSC configuration to set the DNS Server.

I am running all the following scripts from PowerShell console as Administrator on Windows Server 2016 Hyper-V TP4 host domain joined and not from PowerShell ISE.  

Step 1: Create Nano Server Image
In this step, I will combine point 1 through 4 in one script:

If you noticed in above script, we are able to inject the IPv4Address, IPv4SubnetMask and IPv4Gateway. Unfortunately, the DNS Server address is not injected at the time of image creation, this parameter is not included yet in Nano PowerShell module in TP4. The DNS Server is very important when Nano Server is joined to the domain.

Step 2: Create Nano Virtual Machines

In this step, I will create 4 Nano Virtual Machines.

Step 3: Download and Import DSC xNetworking Module

In this step, I will download and import the xNetworking module which is a part of the DSC Resource Kit produced by the PowerShell Team. This module contains the xIPAddress and xDnsServerAddress resources that allow configuration of a node’s IP Address and DNS Server Address.

In the first part of the script, I downloaded the module from PowerShell gallery locally and then I copied it through PowerShell remote session to all Nano Servers instead of download it again from the Internet. This is just awesome.

In PowerShell V5.0, you can copy and send files over PowerShell remote session without the need to use network shares!

As a side note, Windows Management Framework (WMF) 5.0 is now available which is bring support for all the goodness of PowerShell V5.0 to down-level OS (Windows Sever 2012 R2, Windows Server 2012, Windows Server 2008 R2 SP1, Windows 10 Version 1511, Windows 8.1 and Windows 7 SP1).


Step 4: Push DSC Configuration

Before we push the DSC configuration and set the DNS server, I will pull the current DNS address from each Nano Server.

As you can see, we don’t have any IP Address set yet.


I will push the DSC configuration now to all Nano machines.

Count until 5… and Boom!


Last but not least, let’s confirm the DNS address is set on all Nano machines.

Yes indeed!


With that I will sign-off for 2015.

I want to thank the Community, Followers, Readers, Microsoft Product Teams, MVP Award Program, MVP’s, Developers and ITPro’s!

Until then… see you in 2016…

Happy Holidays!

Cheers,
-Charbel

About Charbel Nemnom 299 Articles
Charbel Nemnom is a Microsoft Cloud Consultant and Technical Evangelist, totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 15 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design and virtualization.

Be the first to comment

Leave a Reply