I have built a nested ARM template which sets the VM up and adds it to the Azure DSC Automation server for final configuration. This setup utilises the following Git resource to setup the pull server:
This source uses the DSC extension within the ARM template to configure the VM for where the pull server is, registration key, settings, and which DSC Node Configuration to apply, which is where I have everything to configure the machine.
Part of my DSC configuration requires the machine description to be updated:
Registry ChangeDescription
{
Ensure = "Present"
Key = "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
ValueName = "srvcomment"
ValueData = "my-super-awesome-computer-description"
ValueType = "String"
}
I want to have the ability for my ARM template to pass a parameter to the DSC configuration where the end user had typed the computer description at the time of ARM deployment (I will be using Azure templates deployment as a 'stock' image for people to use).
Azure templates: https://portal.azure.com/#blade/HubsExtension/Resources/resourceType/Microsoft.Gallery%2Fmyareas%2Fgalleryitems
ARM parameter:
"computerDescription": {
"type": "string",
"metadata": {
"description": "The description name of the VM."
}
},
Microsoft.Compute/virtualMachines/extensions properties:
{
"Name": "computerDescription",
"Value": "[parameters('computerDescription')]",
"TypeName": "System.String"
}
DSC:
Registry ChangeDescription
{
Ensure = "Present"
Key = "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters"
ValueName = "srvcomment"
ValueData = $ComputerDescription
ValueType = "String"
}
Going by the source on Git, I know you can pass parameters to the DSC file as that's how the machine gets set up, but I can only see it being passed to the .ps1 script that actually sets the machine up for DSC. Thus I don't see how the parameter could be passed onto the next stage where my node configuration completes the setup.
I don't necessarily need this to be setup at the DSC point, it could be done via the template if I knew how, or perhaps somewhere else that someone might know of? Essentially it only needs to be set once.
Any ideas, please?
EDIT for 4c74356b41 question.
I'm still not sure how to use the parameter computerDescription
as a string to commandToExecute
. This is the PS script I came up with, but no real idea how to make that string into a variable for PS.
Param ( [string] $psVariable )
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\" -Name "srvcomment" -Value $psVariable -PropertyType String
And this is the commandToExecute
I have
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', variables('asdfcseScriptFolder'), '/', variables('asdfcseScriptFileName'))]"
I'm not sure where to put computerDescription
parameter in there...?