Zhixian's Tech Blog

2019-01-12

Installing PowerShell Core

Filed under: computing, software, windows — Tags: , , , — Zhixian @ 23:42:01 pm

This blog post is a reminder to myself on the installation process for PowerShell Core.

What is PowerShell Core?

PowerShell Core is a version of PowerShell based on .NET Core.
The idea is to bring PowerShell across to platforms other than Windows (for example Linux, and macOS).

Images of PowerShell Core Installation (for Windows)

The installer for PowerShell Core can be found at https://github.com/PowerShell/PowerShell.

If you browse to this page, you’ll see the Windows Installer somewhere on the middle of the page.

image

After you clicked on the link, an installation file should be downloaded to your computer.
After the file has finish downloading, you should see the downloaded file which is named something like “PowerShell-<version>-<platform>.msi”.

image

Double-clicking the file will start the installation process.
After the installation process startup, you will see a screen like the below.
Click on the “Next” button to proceed with the installation process.

image

After you clicked on the next button, you will come to the “End-User License Agreement” dialog.
Checked on the “I accept the terms in the License Agreement” checkbox.
Click on the “Next” button to proceed with the next step of the installation process.

image

After you clicked on the “Next” button, you will see the “Destination Folder” dialog.
You can choose to change the installation location of the PowerShell Core, if you would like to install it to a location other than its default (which is “C:\Program Files\PowerShell\”).
After you set the location, clicked on the “Next” button to proceed with the next step of the installation process.

image

After you clicked on the next button, you will see the “Optional Actions” dialog.

Accept the default checked items, and clicked on the “Next” button to proceed.

image

After you clicked on the next button, you are finally ready to install PowerShell Core.
Click on the “Install” button to proceed with the installation.

image

After you clicked on the install button, the installation process will install PowerShell Core.

image

After the installation is complete, you will see a screen like the below.
Click on the “Finish” button to complete the installation process.

image

After closing the installation dialog, you can run PowerShell from Windows Start Menu by clicking on the item labeled “PowerShell 6 (x64)”.

image

This is bring up the PowerShell Core command-line shell.
Type “$PSVersionTable” on the command-line to see the version of the PowerShell that you are running.

Things to note are PSVersion and PSEdition.
PSEdition should read “Core” and PSVersion should report the version of PowerShell Core that you are running.

image

At this point, if you see a screen like the above, it means you have a running copy of PowerShell Core.

Advertisements

2017-07-12

Using ACMESharp to get SSL certificates from Let’s Encrypt

This blog post is a reminder note to myself on how to use the ACMESharp PowerShell module to get SSL certificates from Let’s Encrypt CA.

Essentially, the usage can be divided into the following phases:

  1. Install ACMESharp PowerShell module
  2. Import ACMESharp PowerShell module
  3. Initial (one-time) setup
  4. Register DNS of certificate
  5. Get “challenge” details (to prove that you are the owner of the domain)
  6. Signal Let’s Encrypt to confirm your challenge answer
  7. Download certificates

Steps 1-3 is only for setting up on a new PC.
Step 2, 4 should be repeated for each domain that you want SSL certificates for.
Steps 2, 5-7 should be repeated whenever you want to get or renew certificate.

1. Install ACMESharp PowerShell module

Install-Module -Name ACMESharp -AllowClobber

2. Import ACMESharp PowerShell module

Import-Module ACMESharp

 

3. Initial (one-time) setup

Initialize-ACMEVault

New-ACMERegistration -Contacts mailto:zhixian@hotmail.com -AcceptTos

4.  Register DNS of certificate

New-ACMEIdentifier -Dns plato.emptool.com -Alias plato_dns

5. Get challenge (to prove that you are the owner of the domain)

Complete-ACMEChallenge plato_dns -ChallengeType http-01 -Handler manual

6. Signal Let’s Encrypt to confirm your challenge answer

Submit-ACMEChallenge plato_dns -ChallengeType http-01
(Update-ACMEIdentifier plato_dns -ChallengeType http-01).Challenges | Where-Object {$_.Type -eq “http-01”}
New-ACMECertificate plato_dns -Generate -Alias plato_cert1
Submit-ACMECertificate plato_cert1
Update-ACMECertificate plato_cert1

7. Download certificates

NGINX

Get-ACMECertificate plato_cert1 -ExportCertificatePEM “C:\src\certs\plato_cert1.crt.pem”
Get-ACMECertificate plato_cert1 -ExportIssuerPEM “C:\src\certs\plato_cert1-issuer.crt.pem”

Add-Content -Value (Get-Content plato_cert1.crt.pem) -Path nginx.plato.emptool.com.pem
Add-Content -Value (Get-Content plato_cert1-issuer.crt.pem) -Path nginx.plato.emptool.com.pem

HAPROXY

ZX: Generating SSL certificates for HAPROXY is similar to NGINX, except it includes a key.

Get-ACMECertificate plato_cert1 -ExportKeyPEM “C:\src\certs\plato_cert1.key.pem”
Get-ACMECertificate plato_cert1 -ExportCertificatePEM “C:\src\certs\plato_cert1.crt.pem”
Get-ACMECertificate plato_cert1 -ExportIssuerPEM “C:\src\certs\plato_cert1-issuer.crt.pem”

Add-Content -Value (Get-Content plato_cert1.crt.pem) -Path haproxy.plato.emptool.com.pem
Add-Content -Value (Get-Content plato_cert1-issuer.crt.pem) -Path haproxy.plato.emptool.com.pem
Add-Content -Value (Get-Content plato_cert1.key.pem) -Path haproxy.plato.emptool.com.pem

 

IIS

Get-ACMECertificate plato_cert1 -ExportPkcs12 “C:\src\certs\iis.plato_cert1.pfx”

 

Blog at WordPress.com.