Example/LabSetup.ps1

using module DSCPullServerLab
using module Microsoft.PowerShell.Management
using module Microsoft.PowerShell.Utility
<#
.EXAMPLE
    .\LabSetup.ps1 -ISODestinationPath 'E:\Hyper-V\WindowsServer.iso' -ParentVHDDestinationPath 'E:\Hyper-V\ParentVHD.vhdx' -VMRootPath 'E:\Hyper-V' -TargetNodeNames 'WFE-Development', 'WFE-Test', 'WFE-Acceptance', 'WFE-Production' -TargetNodeRamMB 1024
    This command will create a secure DSC pull server and four target nodes
.EXAMPLE
    .\LabSetup.ps1 -ISODestinationPath 'E:\Hyper-V\WindowsServer.iso' -ParentVHDDestinationPath 'E:\Hyper-V\ParentVHD.vhdx' -VMRootPath 'E:\Hyper-V'
    This command will create a secure DSC pull server
#>

[CmdletBinding()]
param(
    #region environment specific parameters

    # this password will be allocated to the new built-in administrator account
    # enter the existing password if vms have already been created with this script
    [securestring]$Password,

    $ISODestinationPath,

    $ParentVHDDestinationPath,

    $VMRootPath,

    #endregion environment specific parameters

    # will overwrite everything and re-download the iso
    [switch]$Force,

    [Parameter (ParameterSetName = 'TargetNodes')]
    [string[]]$TargetNodeNames,

    # region params with defaults that can be overridden
    [parameter(Mandatory = $true, ParameterSetName = 'TargetNodes')]
    [parameter(Mandatory = $false, ParameterSetName = 'Default')]
    [int]$TargetNodeRamMB     = 1024,
    [int]$DSCPullServerRamMB  = 4096,    
    $ParentVHDLocale          = 'en-gb',
    $ParentVHDTimeZone        = 'GMT Standard Time',
    $DSCPullServerName        = 'DSCPullServer',
    # params prefixed with 'VM' only apply to the DSCPullServer
    # the pull server will be provisioned as a DHCP / DNS server to configure networking on nodes
    $VMIPAddress              = '10.0.0.10',
    $VMSubnetBits             = 24,
    $VMDNSServers             = '10.0.0.10',
    $VMDefaultGateway         = '10.0.0.254',
    $VirtualSwitchName        = 'DSCPullServerLab',
    $StartVMs                 = $true
    # endregion region params with defaults that can be overridden
)
$ErrorActionPreference = 'Stop'

if ( !$psBoundParameters.ContainsKey('ParentVHDLocale') ) {
 $psBoundParameters.ParentVHDLocale = $ParentVHDLocale
}
if ( !$psBoundParameters.ContainsKey('ParentVHDTimeZone') ) {
 $psBoundParameters.ParentVHDTimeZone = $ParentVHDTimeZone
}
if ( !$psBoundParameters.ContainsKey('DSCPullServerName') ) {
 $psBoundParameters.DSCPullServerName = $DSCPullServerName
}
if ( !$psBoundParameters.ContainsKey('DSCPullServerRamMB') ) {
  $psBoundParameters.DSCPullServerRamMB = $DSCPullServerRamMB
}
if ( !$psBoundParameters.ContainsKey('VMIPAddress') ) {
 $psBoundParameters.VMIPAddress = $VMIPAddress
}
if ( !$psBoundParameters.ContainsKey('VMSubnetBits') ) {
 $psBoundParameters.VMSubnetBits = $VMSubnetBits
}
if ( !$psBoundParameters.ContainsKey('VMDNSServers') ) {
 $psBoundParameters.VMDNSServers = $VMDNSServers
}
if ( !$psBoundParameters.ContainsKey('VMDefaultGateway') ) {
 $psBoundParameters.VMDefaultGateway = $VMDefaultGateway
}
if ( !$psBoundParameters.ContainsKey('VirtualSwitchName') ) {
 $psBoundParameters.VirtualSwitchName = $VirtualSwitchName
}
if ( !$psBoundParameters.ContainsKey('StartVMs') ) {
    $psBoundParameters.StartVMs = $StartVMs
}
if ( !$Password ) {
    $Password = (Read-Host -Prompt "Enter password for the built-in administrator account(s)" -AsSecureString)
}

$Credential = New-Object System.Management.Automation.PSCredential('Administrator', $Password)
$psBoundParameters.Remove('Password') | Out-Null
$psBoundParameters += @{Credential = $Credential}           

New-DSCPullServerLab @psBoundParameters -Verbose