How it works...

In step 1, you create a self-signed certificate with a subject name of SRV1. The New-SelfSignedCertificate creates this certificate in the local machine's MY folder. There is no output from this step, but the certificate is stored in the $DscCert variable for use in the next step. This recipe uses this certificate to provide SSL access to the DSC web service.

In step 2, you copy the certificate to the root store on SRV2. Unfortunately, the certificate provider in PowerShell does not support copying a certificate from one store to another, so you need to dip down into the .NET framework to add the self-signed certificate held in $DscCert to the SRV2 server's local machine trusted root store. This has the effect of enabling ...

Get Windows Server 2016 Automation with PowerShell Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.