This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Assuming you already have this hashtable | |
| $MyHash = @{ | |
| Ensure = 'Present' | |
| Name = 'Putty' | |
| Version = 'Latest' | |
| ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' } | |
| } | |
| Configuration MyDscConfig { | |
| $Allnodes.nodename { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Assuming you already have this hashtable | |
| $MyHashes = @( | |
| @{ | |
| Ensure = 'Present' | |
| Name = 'Putty' | |
| Version = 'Latest' | |
| ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' } | |
| }, | |
| @{ | |
| Ensure = 'Absent' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Assuming you already have this hashtable | |
| $MyHashes = @( | |
| @{ | |
| Ensure = 'Present' | |
| Name = 'Putty' | |
| Version = 'Latest' | |
| ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' } | |
| }, | |
| @{ | |
| Ensure = 'Absent' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| configuration MyConfig { | |
| Param() | |
| if($Node.Role -contains 'DHCPData' -and $Node.Customers -eq 'CustomerA') { | |
| $Domain = $ConfigurationData.customerA.Domain | |
| } | |
| else { | |
| $Domain = $ConfigurationData.DefaultDomain.Domain | |
| } | |
| File MyDomainFile { | |
| Ensure = 'Present' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Configuration MyDSCConfig { | |
| Node $ConfigurationData.AllNodes.nodename { | |
| if($Node.roles -contains 'MyRole') { | |
| # do stuff here, like calling DSC Resources | |
| MyCompositeResource StuffForMyRole { | |
| # ... | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ConfigurationData = @{ | |
| AllNodes = @( | |
| @{ | |
| Nodename = 'SRV01' | |
| Role = 'ServerType1_Application' | |
| }, | |
| @{ | |
| Nodename = 'SRV02' | |
| Role = 'ServerType2_Application' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foreach($Node in $ConfigurationData.AllNodes) { | |
| # Retrieving the DSC Composite Resource name to include | |
| $configurations = $ConfigurationData.Roles.($Node.Role).configurations | |
| foreach($ConfigurationName in $configurations) { | |
| $ConfigurationParameters = $ConfigurationData.Roles.($Node.Role).($ConfigurationName) | |
| # Splat the Configuration Parameters defined in the Role to the Composite resource | |
| &$ConfigurationName @ConfigurationParameters | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Global:Get-DscSplattedResource { | |
| [CmdletBinding()] | |
| Param( | |
| [String] | |
| $ResourceName, | |
| [String] | |
| $ExecutionName, | |
| [hashtable] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Configuration MyDscConfig { | |
| # Import the module that has the 'ServerType' configuration | |
| Import-DscResource -ModuleName Platform | |
| # Import the module that has the 'Application' Configuration | |
| Import-DscResource -ModuleName Product | |
| $ConfigurationData.AllNodes.Nodename { | |
| $ConfigurationData.Roles.($Node.Role).configurations.Foreach{ | |
| $ConfigurationName = $_ | |
| $ConfigurationParameters = $ConfigurationData.Roles.($Node.Role).($ConfigurationName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Invoke-TestHandlerAction { | |
| Param( | |
| $Password, | |
| $test, | |
| $Datum, | |
| $Node, |