I have a DSC configuration that looks like this
configuration DBServer
{
param(
[PSCredential]$SqlAdminCredential
)
node "localhost"
{
Script ConfigureSSRS {
SetScript = {
& sqlcmd -S $RSConnection -i $DBCreateFile -U $SQLAdminCredential.UserName -P $SQLAdminCredential.GetNetworkCredential().Password
I'm running it on azure VMs using a JSON template deployment with a DSC extension containing this Properties
node:
"Properties": {
"SqlAdminCredential": {
"userName": "PrivateSettingsRef:SQLAdmin",
"password": "PrivateSettingsRef:SQLAdminPass"
},
Those two value are indeed defined in the protectedSettings
node:
"SQLAdmin": "[parameters('sqlAuthenticationLogin')]",
"SQLAdminPass": "[parameters('sqlAuthenticationPassword')]"
But I keep getting null reference exceptions in the code I listed above whenever I try to use the credentials. I've tried $using:SqlAdminCredential
and I believe yesterday I tried $global:SqlAdminCredential
as well.
I'm currently attempting to troubleshoot this but I don't like making a change to my configuration and then spending 15 minutes waiting for a deploy to see if it worked. However, I can't figure out how to pass this credential object parameter using Start-DscConfiguration
in order to troubleshoot it on an existing VM. How can I do this?
Bonus points if you can fix my actual problem and tell me how to access $SqlAdimCredential
from inside ConfigureSSRS.SetScript
For the moment, I have decided to be poorly behaved and do this:
configuration DBServer
{
param(
[PSCredential]$SqlAdminCredential
)
node "localhost"
{
$adminCreds = $SqlAdminCredential #a hack
Script ConfigureSSRS {
SetScript = {
$SqlAdminCredential = $using:adminCreds
I will wait for a better solution but this appears to be working.