Verbose "Virtual Subnet ID is: $VMSubnetID" #Build a list of rules to run $RulesToRun = @ ( ) #Iterate each rule the user has defined Write-Verbose "Iterating through each Rule to apply building complete list to apply. There are $ ($PortRules. Count) to apply. " ForEach ($Rule in $PortRules) { #Format the baseline of the rule to add the basic rule parameters $ExprToRun = $BaseLine -f $Rule.Action,$Rule.Direction, $VmmVm. Name, $Rule. Weight, $VMSubnetID #Is it ICMP traffic? If ($Rule. Protocol -eq "1") { $ExprToRun += " -Protocol 1" }elseif ($Rule. Protocol) { #Make it stateful $ExprToRun += $StatefulBase -f $Rule.LocalPort,$Rule.Protocol #Add to the list $RulesToRun += $ExprToRun #Execute the rules on the remote host Network Access Control Lists Write-Verbose "Adding rules to " " $ ($VM.Trim())" using remote Powershell on VM host " $ ($VmmVm.HostName) Invoke-Command - - -ComputerName $VmmVm.HostName - ScriptBlock { #Get the Rules to process Param ( [string [] ] $Rules #Iterate each rule ForEach ($Rule in $Rules) { #Check the rule is not blank if ($Rule) { Invoke-Expression $Rule -ArgumentList (, $RulesToRun) #the (, <VAR>) syntax ensures the variable is passed as an array Write-Verbose "Process complete for " $ $ ($VM. Trim ( ) ) " Write-Verbose "Process complete" VM Templates The recipes in this book use a simple Virtual Machine Template (VM Template). It was created using the Convert-WindowsImage ps1 PowerShell script. This script can be downloaded from https://gallery.technet.microsoft.com/scriptcenter/ Convert-WindowsImageps1 - - 0fe23a8f. This script is capable of creating a VHDX file from a Windows Imaging File Format (WIM) file; the install wim file was sourced from the Windows Server 2012 R2 ISO file. VM Templates The following screenshot shows how the VHDX file was created: Convert-Windowslmage UI You can use the fields below to configure the VHD or VHDX that you want to create! 1. Choose a source C:\VMs\ISOs\en_windows_server_2012_r2_with_update_x64_dvd_40652 2. Choose a SKU from the list ServerStandar