From ddd0560e5dbec26895506fd1f17a5fdd325d448e Mon Sep 17 00:00:00 2001 From: jowj Date: Mon, 9 Jul 2018 19:58:46 -0500 Subject: [PATCH] add scripts for a simple private network. --- .../ConfigurationData.SIMPLENET.psd1 | 36 +++++++++++++ simplePrivateNet/Configure.SIMPLENET.ps1 | 50 +++++++++++++++++++ simplePrivateNet/Deploy-SIMPLENET.ps1 | 14 ++++++ 3 files changed, 100 insertions(+) create mode 100644 simplePrivateNet/ConfigurationData.SIMPLENET.psd1 create mode 100644 simplePrivateNet/Configure.SIMPLENET.ps1 create mode 100644 simplePrivateNet/Deploy-SIMPLENET.ps1 diff --git a/simplePrivateNet/ConfigurationData.SIMPLENET.psd1 b/simplePrivateNet/ConfigurationData.SIMPLENET.psd1 new file mode 100644 index 0000000..8b7a2da --- /dev/null +++ b/simplePrivateNet/ConfigurationData.SIMPLENET.psd1 @@ -0,0 +1,36 @@ +@{ + AllNodes = @( + @{ + NodeName = '*'; + InterfaceAlias = 'Ethernet'; + AddressFamily = 'IPv4'; + Lability_SwitchName = "Wifi-HyperV-VSwitch"; + Lability_Media = 'WIN10_x64_Enterprise_EN_Eval'; + Lability_ProcessorCount = 1; + Lability_StartupMemory = 2GB; + PSDscAllowPlainTextPassword = $true; + } + @{ + NodeName = 'CLIENT1'; + Role = 'CLIENT'; + IPAddress = '10.0.0.1/24'; + } + @{ + NodeName = 'CLIENT2'; + Role = 'CLIENT'; + IPAddress = '10.0.0.2/24'; + } + ); + NonNodeData = @{ + Lability = @{ + EnvironmentPrefix = 'SIMPLENET-'; + Network = @( + @{ Name = 'CORP'; Type = 'Private'; } + ) + DSCResource = @( + @{ Name = 'xComputerManagement'; RequiredVersion = '4.1.0.0'; } + @{ Name = 'xNetworking'; RequiredVersion = '5.7.0.0'; } + ); + }; + }; +}; \ No newline at end of file diff --git a/simplePrivateNet/Configure.SIMPLENET.ps1 b/simplePrivateNet/Configure.SIMPLENET.ps1 new file mode 100644 index 0000000..74afeec --- /dev/null +++ b/simplePrivateNet/Configure.SIMPLENET.ps1 @@ -0,0 +1,50 @@ +Configuration SimpleNetworkConfig { + param () + + Import-DscResource -Module PSDesiredStateConfiguration + + Import-DscResource -Module xComputerManagement -ModuleVersion 4.1.0.0 + Import-DscResource -Module xNetworking -ModuleVersion 5.7.0.0 + + # Common configuration for all nodes + node $AllNodes.Where({$_.Role -in 'CLIENT'}).NodeName { + + LocalConfigurationManager { + RebootNodeIfNeeded = $true; + AllowModuleOverwrite = $true; + ConfigurationMode = 'ApplyOnly'; + } + + xFirewall 'FPS-ICMP4-ERQ-In' { + Name = 'FPS-ICMP4-ERQ-In'; + DisplayName = 'File and Printer Sharing (Echo Request - ICMPv4-In)'; + Description = 'Echo request messages are sent as ping requests to other nodes.'; + Direction = 'Inbound'; + Action = 'Allow'; + Enabled = 'True'; + Profile = 'Any'; + } + + xFirewall 'FPS-ICMP6-ERQ-In' { + Name = 'FPS-ICMP6-ERQ-In'; + DisplayName = 'File and Printer Sharing (Echo Request - ICMPv6-In)'; + Description = 'Echo request messages are sent as ping requests to other nodes.'; + Direction = 'Inbound'; + Action = 'Allow'; + Enabled = 'True'; + Profile = 'Any'; + } + + xIPAddress 'PrimaryIPAddress' { + IPAddress = $node.IPAddress + InterfaceAlias = $node.InterfaceAlias + AddressFamily = $node.AddressFamily + } + + xComputer 'Hostname' { + Name = $node.NodeName; + } + + } + +} \ No newline at end of file diff --git a/simplePrivateNet/Deploy-SIMPLENET.ps1 b/simplePrivateNet/Deploy-SIMPLENET.ps1 new file mode 100644 index 0000000..681553a --- /dev/null +++ b/simplePrivateNet/Deploy-SIMPLENET.ps1 @@ -0,0 +1,14 @@ +[CmdletBinding()] Param( + [SecureString] $AdminPassword = (Read-Host -AsSecureString -Prompt "Admin password"), + [string] $ConfigurationData = (Join-Path -Path $PSScriptRoot -ChildPath ConfigurationData.SIMPLENET.psd1), + [string] $ConfigureScript = (Join-Path -Path $PSScriptRoot -ChildPath Configure.SIMPLENET.ps1), + [string] $DscConfigName = "SimpleNetworkConfig", + [switch] $IgnorePendingReboot +) + +$ErrorActionPreference = "Stop" + +. $ConfigureScript +& $DscConfigName -ConfigurationData $ConfigurationData -OutputPath $env:LabilityConfigurationPath -Verbose +Start-LabConfiguration -ConfigurationData $ConfigurationData -Path $env:LabilityConfigurationPath -Verbose -Password $AdminPassword -IgnorePendingReboot:$IgnorePendingReboot +Start-Lab -ConfigurationData $ConfigurationData -Verbose \ No newline at end of file