OK, so I wound up using this in the DSC file that configures my second domain controller:
Script ParametersFile
{
GetScript = {
@{ Result = (Get-Content 'C:\creds.txt') }
}
TestScript = {
Test-Path 'C:\creds.txt'
}
SetScript = {
"Domain: $using:DomainName" | Out-File 'C:\creds.txt'
"Admincreds.username: $($using:Admincreds.UserName)" | Out-File 'C:\creds.txt' -Append
"Admincreds.password.length: $($using:Admincreds.Password.Length)" | Out-File 'C:\creds.txt' -Append
"Domaincreds.username: $($using:DomainCreds.UserName)" | Out-File 'C:\creds.txt' -Append
"Domaincreds.password.length: $($using:DomainCreds.Password.Length)" | Out-File 'C:\creds.txt' -Append
}
}
That worked to grab the username, and the length of the password. When I set my DSC resource without using protected settings, everything built out fine, and the file on C was what I expected.
"resources": [
{
"name": "CreateSecondDC",
"type": "extensions",
"location": "[resourceGroup().location]",
"apiVersion": "2016-03-30",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('GTM-DC02Name'))]",
"[concat('Microsoft.Compute/virtualMachines/', parameters('GTM-Server01Name'),'/extensions/Server1JoinDomain')]"
],
"tags": {
"displayName": "DC02DSC"
},
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.20",
"autoUpgradeMinorVersion": true,
"settings": {
"wmfVersion": "latest",
"configuration": {
"url": "[variables('DSCURL')]",
"script": "[variables('DC02DSCscript')]",
"function": "[variables('DC02DSCfunction')]"
},
"configurationdata": {
"url": "[concat(parameters('assetLocation'), variables('adPopulationData'))]"
},
"configurationArguments": {
"DomainName": "[parameters('domainName')]",
"adminCreds": {
"userName": "[parameters('GTM-DC01AdminUserName')]",
"password": "[parameters('GTM-DC01AdminPassword')]"
}
}
},
"protectedSettings": {
}
}
}
]
With that, I see this in the file I am creating with the script resource:
Domain: gametimeor.priv
Admincreds.username: radcliffe
Admincreds.password.length: 16
Domaincreds.username: gametimeor.priv\radcliffe
Domaincreds.password.length: 16
When I set the DSC resource to use protected settings -
[
{
"name": "CreateSecondDC",
"type": "extensions",
"location": "[resourceGroup().location]",
"apiVersion": "2016-03-30",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('GTM-DC02Name'))]",
"[concat('Microsoft.Compute/virtualMachines/', parameters('GTM-Server01Name'),'/extensions/Server1JoinDomain')]"
],
"tags": {
"displayName": "DC02DSC"
},
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.20",
"autoUpgradeMinorVersion": true,
"settings": {
"wmfVersion": "latest",
"configuration": {
"url": "[variables('DSCURL')]",
"script": "[variables('DC02DSCscript')]",
"function": "[variables('DC02DSCfunction')]"
},
"configurationdata": {
"url": "[concat(parameters('assetLocation'), variables('adPopulationData'))]"
},
"configurationArguments": {
"DomainName": "[parameters('domainName')]",
"adminCreds": {
"userName": "[parameters('GTM-DC01AdminUserName')]",
"password": "PrivateSettingsRef:AdminPassword"
}
}
},
"protectedSettings": {
"Items": {
"AdminPassword": "[parameters('GTM-DC01AdminPassword')"
}
}
}
}
]
I get the following in the text file output:
Domain: gametimeor.priv
Admincreds.username: radcliffe
Admincreds.password.length: 32
Domaincreds.username: gametimeor.priv\radcliffe
Domaincreds.password.length: 32
It seems odd that the password length doubles. Does that mean anything to you, or do you think I should file a bug report?
Also, [parameters(‘GTM-DC01AdminPassword’) actually does reference a value in a keyvault, so that seems to be working, just the PrivateSettingsRef piece isn’t.