-
Notifications
You must be signed in to change notification settings - Fork 108
How to get Credentials into a Configuration #115
Comments
You're on the right track. When you use the Add-DscEncryptedPassword command to set up your encrypted credentials in source control, Get-DscConfigurationData will put those all into a hashtable at $ConfigurationData['Credentials']. In combination with that, you might also have a property that you can resolve with Resolve-DscConfigurationProperty to determine which account to use from the Credentials table. Something like this: $accountName = Resolve-DscConfigurationProperty -Node $Node -PropertyName 'TheAccount'
$psCredential = $ConfigurationData['Credentials'][$accountName]
someResource someName
{
Credential = $psCredential
} |
OK after playing around with it I was never able to get your way to work. Exploring the code I found that the issue with calling it the way you described is that the scripts set it as an Object[] not a hashtable as you can see from the code below.
If I were to go into Get-CredentialConfigurationData.ps1 and change
to
I can actually get the objects back like you are suggestion I should be able to:
If it matters I'm on the development branch with WMF 4.0 |
I've been toying with this for a bit but I'm kind of confused on how I'm supposed to get credentials into my configuration using these tools.
My gut instinct is telling me to use Resolve-DscConfigurationProperty but I'm unclear on how to have the node referencing the credentials.
Something like
$script:ConfigurationData['Credentials']['Account'] strikes me as something that would work but again, not really sure.
Also is there a way to pass in passwords separately or do I have to pass in a credential object because MSFT_Credential is being used in the mof file?
The text was updated successfully, but these errors were encountered: