Thursday, 21 December 2017

Using encrypted credentials with DSC


So, to pass credentials to the target machine, you need to do a few things

How to configure DSC to encrypt credentials

In a nutshell, you basically need to deploy a certificate to the target machine and then the management machine encrypts the credentials using the public key of the target machine certificate. More detailed steps below:

  • Connect to each target computer
  • Generate a self-signed certificate
  • Copy the public key to the management computer
  • Configure the Local Configuration Manager with the correct certificate thumbprint for that machine
  • Create the Configuration Data hashtable for use by other configurations

Script to configure DSC credential encryption

If you know me, I can never really do the same thing twice and if it can be automated then it will be automated. So, this script does all the work for you - just run it from your management machine and point it at your target machine. Just note that it only works with Server 2016 or PowerShell v5.

How to run the script? First we copy and paste the above function into a PowerShell window then run this to save our configuration data into $ConfigurationData

$ConfigurationData = Set-DscLCMCertificate -ComputerName litex01 -Verbose


We can now confirm that your configuration data is correct:




Test out DSC credentials

To do this, we’ll save credentials into $Credential then create a configuration that requires credentials and test it out with our configuration data.


We can then check that our text file has been copied over:

Get-Item '\\litex01\c$\temp\testfile1.txt'


All done! Happy configuration management! You can see the full code at


  1. It’s truly nice blog and we offer activation and support service for MS Office.

  2. Nice blog with good content thanks for sharing with us.

    Get how to place the Norton Activation key and apply it to activate your Norton products.
    norton installation with product key /setup

  3. Full control over your funds while perform transactions with bitcoin exchanger trusted fast website working as highest degree of security privacy and professionalism

  4. Your content will continue to follow your blogs with your users who have read your developmental and benefits information.

    Ümraniye Nakliye

    Üsküdar Nakliye

    Ateşehir Nakliye

    Kartal Nakliye

    Maltepe Nakliye

    Kurtköy Nakliye

    Çekmeköy Nakliye

    Sultanbeyli Nakliye


  5. Great post ! I am pretty much pleased with your good post.You put really very helpful information

    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
    สมัครสล็อตออนไลน์ >>> goldenslot
    สนใจร่วมลงทุนกับเรา สมัครเอเย่น Gclub คลิ๊กได้เลย

  6. Excellent Post as always and you have a great post and i like it thank you for sharing

    เว็บไซต์คาสิโนออนไลน์ที่ได้คุณภาพอับดับ 1 ของประเทศ
    เป็นเว็บไซต์การพนันออนไลน์ที่มีคนมา สมัคร Gclub Royal1688
    และยังมีหวยให้คุณได้เล่น สมัครหวยออนไลน์ ได้เลย
    สมัครสมาชิกที่นี่ >>> Gclub Royal1688