Import pfx

This topic contains 1 reply, has 2 voices, and was last updated by

1 month ago.

  • Author
  • #129761

    Points: 53
    Rank: Member

    Hi, I'm trying to import pfx via DSC. My DSC code like that:

    Configuration Main
        Import-DscResource -ModuleName xWebAdministration
        Import-DscResource -ModuleName xPSDesiredStateConfiguration
        Import-DscResource -ModuleName PSDesiredStateConfiguration
        Import-DSCResource -ModuleName xCertificate
        Node localhost
    		xPfxImport mycertCert {
                Thumbprint = 'ef0642af0b31974c0e0cc80dee4c4208fc4d4bc2'
                Path = "D:\Software\mycert.pfx"
                Store = 'My'
                Credential = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString -Key ([system.Text.Encoding]::UTF8).GetBytes("This is a string to hash") "76492d1116743f0423413b16050a5345MgB8AHkAYwBkAG4AMAAzAHoAVABUAHgARQBFAHQAWgBXAGEAWgBxAFgAawBXAGcAPQA9AHwANgA5ADgANAA1ADEAOABhADkAYgA2AGEANQBhADQANQA1AGMAOAA2AGIAMQA1ADkAYwA0AGIANwAzADgAMAAzADUAOQBkAGQAZg
                Location = 'LocalMachine'

    I got this error:

    ConvertTo-MOFInstance : System.InvalidOperationException error processing property 'Credential' OF TYPE 'xPfxImport': Converting and storing encrypted passwords as plain text is not recommended. For more information on securing credentials in MOF file, please refer to MSDN blog:

    I need somehow pass cert password automatically. Any help would be welcome. Thanks in advance

  • #129771

    Points: 1,086
    Helping Hand
    Rank: Community Hero

    Well , you can't use credentials in a DSC resource by default. There are recommendation to do it. Please go through below documentation.

You must be logged in to reply to this topic.