In my previous blog I spoke about configuring an SMB Pull server on Dell PowerEdge R730XD server. In this blog I will be talking about:

1. Configuring an HTTP Pull Server.

2. Setting up a configuration blueprint to install Hyper-V, enable the Failover cluster feature, and configure the internal V-switch on the Hyper-V host

Environment and pre-requisites –

  1. Hardware - Dell PowerEdge R730XD server with Windows Server 2016 RTM installed. Enabled the Hyper-V Role and configure 2 VM’s on the server.

  2. VM1- HTTPPull –-> This VM will be my HTTP Pull Server

  3. VM2- NHV-1 –-> This VM will be my client and I will configure the VM’s Local Configuration Manager (LCM) to pull the configuration from HTTP pull server. I installed the Hyper-V feature on this VM to enable nested virtualization (to do so follow this Microsoft article). You can skip this step if you are using physical host

  4. Install WMF 5.0 if you are using Server 2012 or older OS. Here is the download link. Windows Server 2016 has the latest Windows Management Framework (WMF) native.

  5. Download and save the following modules on your HTTPPull Server

    • xHyper-v (Save-Module -Name xHyper-v -Path 'C:\Program Files\WindowsPowerShell\DscService\Modules')

    • xPSDesiredStateConfiguration (Save-Module -Name xPSDesiredStateConfiguration -Path 'C:\Program Files\WindowsPowerShell\DscService\Modules')

    • NuGet ( Save-Module -Name NuGet -Path 'C:\Program Files\WindowsPowerShell\DscService\Modules')

Once all the pre-requisites are met there are 6 simple steps to:

  1. Configure HTTP pull server.

  2. Point clients to the pull server for them to get their desired state configuration.

Configure HTTP Pull Server

1. Generate Configuration .MOF file -

We need to run the script below to generate a MOF file which has the configuration details to configure the pull server. When you run the MOF file generated, it will install the IIS role if it is not already installed, and start configuring the Pull server.

 

Configuration HTTPPullServer

{

   # Module must exist on Pull server

Import-DscResource -ModuleName xPSDesiredStateConfiguration

 

       # Load the Windows Server DSC Service feature

 

       Node HTTPPull

       {

             WindowsFeature DSCServiceFeature

             {

                 Ensure = 'Present'

                 Name = 'DSC-Service'

             }

 

       # Use the DSC Resource to simplify deployment of the web service

 

       xDSCWebService PSDSCPullServer

       {

         Ensure = 'Present'

         EndpointName = 'PSDSCPullServer'

         Port = 8080

         PhysicalPath = "$env:SYSTEMDRIVE\inetpub\wwwroot\PSDSCPullServer"

         CertificateThumbPrint = 'AllowUnencryptedTraffic'

         ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"

         ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"

         State = 'Started'

         DependsOn = '[WindowsFeature]DSCServiceFeature'

       }

   }

}

 

# Running this Script will Generate a .Mof file in the location below

HTTPPullServer -OutputPath 'C:\PullServerConfig\'

 

At this point you will have a MOF file generated on your workstation/management station in the C:\PullserverConfig directory

2. Push the configuration to the server -

Use the command below to push the configuration from your local management box to your HTTP Pull server

Start-DscConfiguration -Path 'C:\PullServerConfig\' -ComputerName HTTPPull -Wait -Force -Verbose

 

Running the above command will set the VM (HTTPPull) as HTTP Pull server

Click to enlarge the picture

You can simplify a check against the HTTP Pull server using the function below. If you do not use the default service URL, you will need to adjust accordingly

 

function Verify-DSCPullServer ($fqdn) {

   ([xml](invoke-webrequest "http://$($fqdn):8080/psdscpullserver.svc" | % Content)).service.workspace.collection.href

}

Verify-DSCPullServer 'HTTPPull.test.local'

 

If you see the output as shown below after running the function your HTTP Pull server is communicating as expected.

 

## Expected Result: ####Do not Run this##

#Configurations

#Modules

#Action

#Module

#StatusReport

#Node

#Reports

#Nodes

 

3. Create .MOF file to Configure LCM (Local Configuration Manager) for your clients -

 

Now that we have the HTTP pull server setup, configure the client LCM to pull the configuration from HTTP pull server.

 

Run the PowerShell script to create a Meta.MOF file which has the configuration details

 

[DSCLocalConfigurationManager()]

Configuration LCM_HTTPPULL

{

   param

       (

           [parameter(Mandatory=$true)]

           [String[]]$ComputerName,

 

           [parameter(Mandatory=$true)]

           [String]$guid

       )

 

   Node $ComputerName

   {

       settings {

 

           AllowModuleOverwrite = $true

           ConfigurationMode = 'ApplyandAutoCorrect'

           RefreshMode = 'Pull'        

           ConfigurationID = $guid        

           RebootNodeIfNeeded = $true          

       }

           ConfigurationRepositoryWeb DSCHTTP {                          

               ServerURL = 'http://HTTPPull.domain.local:8080/PSDSCPullServer.svc'

               AllowUnsecureConnection = $true          

           }

   }

}

# Computer list

$COMPUTERNAME= 'NHV1‘

 

# Create Guid for the computers (Either you can create a new GUID or use existing one.In the example below I am using the existing GUID)

$guid= '4c060e4d-0e59-422e-935a-11a8f4283c41'

 

# Create the computer Meta.Mof in folder

LCM_HTTPPULL -ComputerName $COMPUTERNAME -Guid $guid -OutputPath C:\PullServerConfig

 

4. Set the Local Configuration Manager of your client machine -

 

Now that we have the configuration Meta.MOF file created, we need to run the Meta.MOF file and set the LCM of the clients. Use the command below to do that.

Running this command will modify the DSCLocalConfigurationManager properties

 

Set-DscLocalConfigurationManager -ComputerName $COMPUTERNAME -Path C:\PullServerConfig -Verbose

Click to enlarge the picture

Here is the screenshot of the DSCLocalConfigurationManager before and after configuring NHV-1 VM to pull the configuration


Click to enlarge the picture

5. Create a configuration blueprint -

The script below creates the configuration .MOF file to configure the client computers with Hyper-V role, Failover cluster Role, and installs all necessary roles needed to manage those roles and also creates the internal V-switch  

configuration HyperVbuild

{

     param (

               [string]$NodeName = 'HTTP-Computers'

           )

 

         Import-DscResource -ModuleName xHyper-V

     Node $NodeName {

 

           WindowsFeature HyperV {

               Ensure='Present'

               Name='Hyper-V'

           }

 

           WindowsFeature HyperVPowershell {

               Ensure='Present'

               Name='Hyper-V-Powershell'

           }

 

           WindowsFeature FullGUITools {

               Ensure = 'Present'

               Name = 'Hyper-v-tools'              

           }

 

           File VMsDirectory { # (This will create a directory for your VMs in the c:\ drive You can choose to skip this option if you want to use default directory)

               Ensure = 'Present'

               Type = 'Directory'

               DestinationPath = "$($env:SystemDrive)\VMs"

           }

 

           xVMSwitch InternalSwitch {

               DependsOn = '[WindowsFeature]HyperV'

               Ensure = 'Present'

               Name = 'LabInternal'              

               Type = 'Internal'

           }

 

           WindowsFeature FM {

               Ensure = 'Present'

               Name = 'Failover-Clustering'          

           }

 

           WindowsFeature FailoverClusteringTools {

               Ensure = 'Present'

               Name = 'RSAT-Clustering'          

               DependsOn = '[WindowsFeature]FM'

 

       }

 

   }

 

}

 

HyperVBuild -outputpath C:\PullServerConfig

 

Once we have created the Configuration .MOF file for the blueprint, we need to rename the configuration .MOF file with the GUID of the client machine and run the checksum. Below are the commands to use:

Note: You can select and run all the commands once or you can run them separately.

# 1. Grab GUID from one of the machines (These are client machines which we have configured as Pull-clients with LCM)

 

$guid=Get-DscLocalConfigurationManager -CimSession NHV-1 | Select-Object -ExpandProperty ConfigurationID

 

# 2. Run 5.1 and 5.2 both combined

# Here we are inserting the grabbed GUID of the LCM and assigning that GUID to the configuration.mof file. (We need to do this because all the LCM's with that Guid will see the *Backup* feature because even this feature config file has same GUID)

 

# 2.1 Specify the Source path of the configuration

$Source = "C:\PullServerConfig\HTTP-Computers.mof"

 

# 2.2 Destination should be HTTP Configuration folder on the pull Server. Here i am saing the filr to c:\ and then i will copy the GUID.mof and checksum file to the HTTP configuration folder

$dest = "C:\PullServerConfig\$Guid.mof"

 

# 3. Copy

Copy-Item -Path $Source -Destination $Dest

 

# 4. Then on Pull Server make Checksum

New-DscChecksum $Dest

 

6. Copy the configuration and checksum file to HTTP PULL server

 

Now that the Guid.mof file and Guid.mof.checksum file is created on the local folder on your workstation we need to copy those files to HTTPPull server Configuration directory.

"C:\PROGRAMFILES\WindowsPowerShell\DscService\Configuration"

 

Note: I hit an issue when using the xHyper-V resource to create xVMSwitch.via Desired State Configuration of the clients for some reason the clients are not able to pull the xHyper-V resource from Pull server modules repository to configure “Internal Switch”. The workaround for this issue is to copy the xHyper-V resource module locally on your client server’s Modules repository C:\Program Files\WindowsPowerShell\Modules

7. Test and update the configuration

Get-WindowsFeature -ComputerName NHV-1 -Name *hyper-v*,*Failover, RSAT-Clustering # Shouldn't be installed yet

Update-DscConfiguration -ComputerName NHV-1 -wait #Check to see if it installs

Get-WindowsFeature -ComputerName NHV-1 -Name *hyper-v*,*Failover*, RSAT-Clustering # Should have installed by now

Test-DscConfiguration -cimsession NHV-1 # Test to see if the computer is in desired state