How it works...

In step 1, you create a self-signed certificate. You drop this certificate both in the LocalMachine\My folder and in the LocalMachine\Root folder. In effect, this creates a trusted certificate on SRV1 that you can use with IIS. Creating the certificate produces no output, but the final command in this step looks like this:

Once you have this certificate on SRV1, you can copy it to the trusted root store on SRV2 This step works by running a script block on the remote machine to make the certificate trusted on SRV2. There is no output from step 2.

In step 3, you display the root certificate added to SRV2 server's trusted root ...

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.