Last active
December 10, 2017 06:26
-
-
Save SpotLabsNET/6732270a0cb3047c29707c6efc8d7e8d to your computer and use it in GitHub Desktop.
This file contains 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
# The DSC configuration that will generate metaconfigurations | |
[DscLocalConfigurationManager()] | |
Configuration MinerConfigMeta | |
{ | |
param | |
( | |
[Parameter(Mandatory=$True)] | |
[String]$RegistrationUrl, | |
[Parameter(Mandatory=$True)] | |
[String]$RegistrationKey, | |
[Parameter(Mandatory=$True)] | |
[String[]]$ComputerName, | |
[Int]$RefreshFrequencyMins = 30, | |
[Int]$ConfigurationModeFrequencyMins = 15, | |
[String]$ConfigurationMode = 'ApplyAndAutoCorrect', | |
[String]$NodeConfigurationName, | |
[Boolean]$RebootNodeIfNeeded= $True, | |
[String]$ActionAfterReboot = 'ContinueConfiguration', | |
[Boolean]$AllowModuleOverwrite = $True, | |
[Boolean]$ReportOnly | |
) | |
if(!$NodeConfigurationName -or $NodeConfigurationName -eq '') | |
{ | |
$ConfigurationNames = $null | |
} | |
else | |
{ | |
$ConfigurationNames = @($NodeConfigurationName) | |
} | |
if($ReportOnly) | |
{ | |
$RefreshMode = 'PUSH' | |
} | |
else | |
{ | |
$RefreshMode = 'PULL' | |
} | |
Node $ComputerName | |
{ | |
Settings | |
{ | |
RefreshFrequencyMins = $RefreshFrequencyMins | |
RefreshMode = $RefreshMode | |
ConfigurationMode = $ConfigurationMode | |
AllowModuleOverwrite = $AllowModuleOverwrite | |
RebootNodeIfNeeded = $RebootNodeIfNeeded | |
ActionAfterReboot = $ActionAfterReboot | |
ConfigurationModeFrequencyMins = $ConfigurationModeFrequencyMins | |
} | |
if(!$ReportOnly) | |
{ | |
ConfigurationRepositoryWeb AzureAutomationDSC | |
{ | |
ServerUrl = $RegistrationUrl | |
RegistrationKey = $RegistrationKey | |
ConfigurationNames = $ConfigurationNames | |
} | |
ResourceRepositoryWeb AzureAutomationDSC | |
{ | |
ServerUrl = $RegistrationUrl | |
RegistrationKey = $RegistrationKey | |
} | |
} | |
ReportServerWeb AzureAutomationDSC | |
{ | |
ServerUrl = $RegistrationUrl | |
RegistrationKey = $RegistrationKey | |
} | |
} | |
} | |
# Create the metaconfigurations | |
$Params = @{ | |
RegistrationUrl = 'https://eus2-agentservice-prod-1.azure-automation.net/accounts/9d25f03f-8cac-4f1b-a03c-5cfa28601df0' | |
RegistrationKey = 'NE7A4HTTXISFJQQFVV5S93/a5zgoOJISmPw78+QCUahq3Xh7uVd1b4gDB6khm3JRlkpk5PYoGlwjqlZM24bqfg==' | |
ComputerName = @("$Env:COMPUTERNAME") | |
NodeConfigurationName = "MinerConfig.miner" | |
RefreshFrequencyMins = 30 | |
ConfigurationModeFrequencyMins = 15 | |
RebootNodeIfNeeded = $true | |
AllowModuleOverwrite = $true | |
ConfigurationMode = 'ApplyAndAutoCorrect' | |
ActionAfterReboot = 'ContinueConfiguration' | |
ReportOnly = $False | |
} | |
$OutputPath = "$PSScriptRoot\.cfgs" | |
if(Test-Path -Path $OutputPath) | |
{ | |
Remove-Item -Path $OutputPath -Recurse -Force | |
} | |
# Use PowerShell splatting to pass parameters to the DSC configuration being invoked | |
# For more info about splatting, run: Get-Help -Name about_Splatting | |
MinerConfigMeta @Params -OutputPath $OutputPath | |
Set-DscLocalConfigurationManager -Path $OutputPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment