O'Reilly logo

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition by Thomas Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Create a self-signed certificate on SRV1, copy it to the local machine's root store, and then display it:
      Get-ChildItem -Path Cert:LocalMachine\My |          Where-Object Subject -eq 'CN=SRV1' |            Remove-Item -Force      $DscCert = New-SelfSignedCertificate `                   -CertStoreLocation 'CERT:\LocalMachine\MY' `                   -DnsName 'SRV1'       $C = 'System.Security.Cryptography.X509Certificates.X509Store'      $Store = New-Object -TypeName $C -ArgumentList       'Root','LocalMachine'      $Store.Open('ReadWrite')      $Store.Add($Dsccert)      $Store.Close()      $DscCert
  1. Copy the certificate to the root store on SRV2 and ensure it's the only one:
      $Sb = {        Param ($Rootcert)         Get-ChildItem Cert:LocalMachine\Root |             Where Subject -eq 'CN=SRV1' | Remove-Item -Force $C = 'System.Security.Cryptography.X509Certificates.X509Store' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required