Facing issue while Encrypting Credentials in DSC MOF Files

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Nitin Gupta Nitin Gupta 6 months, 1 week ago.

  • Author
    Posts
  • #40572
    Profile photo of Yuvaraj Duraisamy
    Yuvaraj Duraisamy
    Participant

    Hi ,

    I have Installed Windows Management Framework (WMF) 5.0 RTM edition that was released 2015-12-17 to encrypti the Credentials in DSC MOF Files. but while try to create the mof, i was getting the error shown below .

    Dsc script
    $ConfigData= @{
    AllNodes = @(
    @{
    # The name of the node we are describing
    NodeName = “localhost”

    # The path to the .cer file containing the
    # public key of the Encryption Certificate
    # used to encrypt credentials for this node"
    CertificateFile ="C:\Publickeys\Pullserver.cer"

    # The thumbprint of the Encryption Certificate
    # used to decrypt the credentials on target node
    Thumbprint ="7af113abe96aede262fe965983248dd533306d7f"
    };
    );
    }

    configuration test

    {
    param(
    [Parameter(Mandatory=$true)]
    [ValidateNotNullorEmpty()]
    [PsCredential] $credential
    )

    Import-DscResource -ModuleName PSDesiredStateConfiguration -ModuleVersion 1.1
    node $AllNodes.NodeName
    {
    File exampleFile
    {
    SourcePath = "\\sptest\C\devcon\devcontest.txt”
    DestinationPath = "\\sptest\C\credsencrpt"
    Credential = $credential
    }

    LocalConfigurationManager
    {
    CertificateId = $node.Thumbprint

    }
    }
    }

    test -configurationdata $ConfigData -outputpath c:\credsencrpt

    Error :

    PS C:\Windows\system32> C:\credsencrpt\creden.ps1
    cmdlet test at command pipeline position 1
    Supply values for the following parameters:
    ConvertTo-MOFInstance : System.Management.Automation.RuntimeException error processing property 'Credential' OF TYPE 'File': Method invocation failed because
    [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache] does not contain a method named 'GetStringFromSecureString'.
    At C:\credsencrpt\creden.ps1:32 char:11
    + File
    At line:297 char:16
    + $aliasId = ConvertTo-MOFInstance $keywordName $canonicalizedValue
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Write-Error], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessProperty,ConvertTo-MOFInstance
    WARNING: It is not recommended to use domain credential for node 'localhost'. In order to suppress the warning, you can add a property named 'PSDscAllowDomainUser' with a value of $t
    rue to your DSC configuration data for node 'localhost'.
    WARNING: The configuration 'test' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource –ModuleName 'PSDesiredStateConfigu
    ration' to your configuration to avoid this message.
    Errors occurred while processing configuration 'test'.
    At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:3705 char:5
    + throw $ErrorRecord
    + ~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (test:String) [], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessConfiguration

    So please guide me to resolve this issue .

  • #40729
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    You want to use WMF 5.0 RTM re-released in Feb instead of Dec one @ https://www.microsoft.com/en-us/download/details.aspx?id=50395.
    I tried it and compilation is succeeding.

You must be logged in to reply to this topic.