Skip to content

Instantly share code, notes, and snippets.

@megamorf
Created April 12, 2016 07:26
Show Gist options
  • Save megamorf/dd095329bb529afe4baa4ebdac13368d to your computer and use it in GitHub Desktop.
Save megamorf/dd095329bb529afe4baa4ebdac13368d to your computer and use it in GitHub Desktop.
DSC - ConfigurationNames with ConfigurationData
@{
AllNodes = @(
@{
NodeName = 'Node1'
Role = 'ExampleRole1'
},
@{
NodeName = 'Node2'
Role = 'ExampleRole2'
},
@{
NodeName = '*'
# Common common node settings
CertificateThumbprint = 'F76C41068D180AE2A34735C22A8251960340220A'
CertificateFile = 'C:\DSC\EncryptionKey.cer'
}
)
}
configuration ExampleConfig
{
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullorEmpty()]
[PsCredential] $SetupSvcCredential,
[Parameter(Mandatory=$true)]
[ValidateNotNullorEmpty()]
[PsCredential] $ConfigSvcCredential
)
Import-DscResource –ModuleName PSDesiredStateConfiguration
node $AllNodes.Where{$_.Role -eq 'ExampleRole1'}.NodeName
{
Log SomeWindowsFeature
{
Message = 'Some Role specific stuff'
}
Script MyScript1
{
GetScript = {}
SetScript = {}
TestScript = {}
Credential = $SetupSvcCredential
DependsOn = '[Log]SomeWindowsFeature'
}
}
node $AllNodes.Where{$_.Role -eq 'ExampleRole2'}.NodeName
{
Log AnotherWindowsFeature
{
Message = 'Other Role specific stuff'
}
Script MyScript2
{
GetScript = {}
SetScript = {}
TestScript = {}
Credential = $ConfigSvcCredential
DependsOn = '[Log]AnotherWindowsFeature'
}
}
}
ExampleConfig -configurationData "$PSScriptRoot\ConfigurationData.psd1"
/*
@TargetNode='Node1'
@GeneratedBy=myuser
@GenerationDate=04/12/2016 09:25:38
@GenerationHost=UNB001
*/
instance of MSFT_LogResource as $MSFT_LogResource1ref
{
SourceInfo = "C:\\Projects\\github\\DSC-ConfigurationNames-Test\\ExampleConfig.ps1::18::9::Log";
ModuleName = "PSDesiredStateConfiguration";
ResourceID = "[Log]SomeWindowsFeature";
Message = "Some Role specific stuff";
ModuleVersion = "1.0";
ConfigurationName = "ExampleConfig";
};
instance of MSFT_Credential as $MSFT_Credential1ref
{
Password = "-----BEGIN CMS-----\nMIIBpAYJKoZIhvcNAQcDoIIBlTCCAZECAQAxggFMMIIBSAIBADAwMBwxGjAYBgNVBAMMEURzY0Vu\nY3J5cHRpb25DZXJ0AhBs3bAEIX8rgkRMf8f3M03vMA0GCSqGSIb3DQEBBzAABIIBAGEYIQo5YAiv\nyV3KN8guuL8pEUO2ebfbl/67z/RKdKnhYQmMuj46KGH9O4RG5CY5H9QopU6q8ebZB8dtuqwR2ogP\nOEnO5Io7kZ6RJ3xp8U01axOntmWmDuRAqfrs7KiuLgTlloVT7TTd/PfvzpdtAiiKNOuDwsLIVakb\nryo4DAGyiB97ipaHkNBhnWSfky2kWThOaQrYP4KDt0PoKm4D2tMENuInc1T62/SuvqWTYxGhdrND\n9qNrA3oLlj6VDT2QR4thGfoYCBPzHeXTwtBdO9Ay9k7HIRoH9k4JFv3V7CQSWvBzLU/aggw3Pe5k\n33zooICaSj/HxFfB8OMGDQNA5ZQwPAYJKoZIhvcNAQcBMB0GCWCGSAFlAwQBKgQQjZ1+TbrugSQg\nScDwi938bYAQ/g6RtF+ZpXWawyGXxtlnTQ==\n-----END CMS-----";
UserName = "a";
};
instance of MSFT_ScriptResource as $MSFT_ScriptResource1ref
{
ResourceID = "[Script]MyScript1";
GetScript = "";
TestScript = "";
SourceInfo = "C:\\Projects\\github\\DSC-ConfigurationNames-Test\\ExampleConfig.ps1::23::9::Script";
SetScript = "";
ModuleName = "PSDesiredStateConfiguration";
Credential = $MSFT_Credential1ref;
ModuleVersion = "1.0";
DependsOn = {
"[Log]SomeWindowsFeature"};
ConfigurationName = "ExampleConfig";
};
instance of OMI_ConfigurationDocument
{
Version="2.0.0";
MinimumCompatibleVersion = "1.0.0";
CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
Author="myuser";
GenerationDate="04/12/2016 09:25:38";
GenerationHost="UNB001";
ContentType="PasswordEncrypted";
Name="ExampleConfig";
};
/*
@TargetNode='Node2'
@GeneratedBy=myuser
@GenerationDate=04/12/2016 09:25:39
@GenerationHost=UNB001
*/
instance of MSFT_LogResource as $MSFT_LogResource1ref
{
SourceInfo = "C:\\Projects\\github\\DSC-ConfigurationNames-Test\\ExampleConfig.ps1::36::9::Log";
ModuleName = "PSDesiredStateConfiguration";
ResourceID = "[Log]AnotherWindowsFeature";
Message = "Other Role specific stuff";
ModuleVersion = "1.0";
ConfigurationName = "ExampleConfig";
};
instance of MSFT_Credential as $MSFT_Credential1ref
{
Password = "-----BEGIN CMS-----\nMIIBpAYJKoZIhvcNAQcDoIIBlTCCAZECAQAxggFMMIIBSAIBADAwMBwxGjAYBgNVBAMMEURzY0Vu\nY3J5cHRpb25DZXJ0AhBs3bAEIX8rgkRMf8f3M03vMA0GCSqGSIb3DQEBBzAABIIBADvKlfZpAmhe\nw+JHeV8WhkSNkRhRMuMSP5gikIIFIbrBIprJvBjkMJYwSLflQo0P+0mbz5LteRinepi9WI19t4VM\n4Uu7HZn60kabGdyS6q6XoFZdGTSgwEkOlrveknKZTe+LSkKASg24q1zCoSvTUXsp/dSA95RPebiN\n2zKTrK1RqxlD882YIMLDT+PxRiH+4/ULY2IiZWF+f1xA8iZl/RS4jO7mGrQYswRe1wOJh4JRS1Dp\nvTT0CNUviEW6/HoLrSqgrGRARB/yM/gApudP20IkcEQmuc5jxqeSR4j0oyj7CWrtsoDGFxPXrtxy\nZX4O/ZNIdskCqaYIlD4vtZkdr9UwPAYJKoZIhvcNAQcBMB0GCWCGSAFlAwQBKgQQqtXT1BQc3Gyq\nfD8Q0gK8b4AQWfIGs/vgwLUMZVYp+wgukw==\n-----END CMS-----";
UserName = "b";
};
instance of MSFT_ScriptResource as $MSFT_ScriptResource1ref
{
ResourceID = "[Script]MyScript2";
GetScript = "";
TestScript = "";
SourceInfo = "C:\\Projects\\github\\DSC-ConfigurationNames-Test\\ExampleConfig.ps1::41::9::Script";
SetScript = "";
ModuleName = "PSDesiredStateConfiguration";
Credential = $MSFT_Credential1ref;
ModuleVersion = "1.0";
DependsOn = {
"[Log]AnotherWindowsFeature"};
ConfigurationName = "ExampleConfig";
};
instance of OMI_ConfigurationDocument
{
Version="2.0.0";
MinimumCompatibleVersion = "1.0.0";
CompatibleVersionAdditionalProperties= {"Omi_BaseResource:ConfigurationName"};
Author="myuser";
GenerationDate="04/12/2016 09:25:39";
GenerationHost="UNB001";
ContentType="PasswordEncrypted";
Name="ExampleConfig";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment