I keep getting an error telling me that PSDscAllowPlainTextPassword needs to be set to true (even though it is)
In this ps1 file I set configuration data, have my DSC configuration, then compile the mof and run it.
You will see that I execute the mof with specific credentials, which are OK, and I also pass in different credentials to be used by the resource, which
$ConfigurationData = @{
AllNodes = @(
@{
NodeName = "*";
PSDscAllowPlainTextPassword = $true
}
)
}
Configuration my_configuration
{
param(
[string] $ComputerName,
[PSCredential] $NonAdminCredentials
)
Import-DscResource -ModuleName my_CompositeResources
Node $ComputerName
{
my_CompositeResource_dostuff DoSomeStuff {
NameOfHost = "$ComputerName"
NonAdminCreds = $NonAdminCredentials
}
}
}
$adminpwd = ConvertTo-SecureString “VerySecretPassword” -AsPlainText -Force
$AdminCreds = New-Object System.Management.Automation.PSCredential (“Administrator”, $adminpwd)
$nonadminpwd = ConvertTo-SecureString “NotSoSecretPassword” -AsPlainText -Force
$NonAdminCreds = New-Object System.Management.Automation.PSCredential (“Bob”, $nonadminpwd)
my_configuration -ConfigurationData $ConfigurationData -ComputerName “bozo” -NonAdminCredentials $NonAdminCreds
Start-DscConfiguration .\my_configuration -Wait -Verbose -Credential $AdminCreds -Force -ErrorAction Stop
.
In my composite resource I am simply setting a service to run under a specific user id (bob).
Configuration my_CompositeResource_dostuff
{
param(
[string] $NameOfHost,
[PSCredential] $NonAdminCreds
)
Service SetupJenkins
{
Name = "jenkins"
State = "Stopped"
StartupType = 'Automatic'
Credential = $NonAdminCreds
}
}
However, I still get the error …
ConvertTo-MOFInstance : System.InvalidOperationException error processing property ‘Credential’ OF TYPE ‘Service’: Converting and storing an encrypted password as plaintext is allowed only if PSDscAllowPlainTextPassword is set to true.
and it points to the line in the composite resource where the Service resource is called from.
Is there something faulty in my logic?