Using PowerShell Core on Windows, Linux and macOS

Windows PowerShell is nothing new. It has been along with Windows for many years. Honestly, I preferred to use CMD more than PowerShell due to the learning cost. In the past few years, under the leadership of Satya Nadella, Microsoft is becoming opened and creative. More and more tools and frameworks support Windows, Linux, and macOS, including Visual Studio Code, .NET Core, and PowerShell. It is so good to use one scripting language for all platforms.

Command Prompt vs. PowerShell

For someone who is familiar with Linux Shell, Command Prompt as a Windows command line tool is probably a nightmare. Let’s try some simple commands to compare Command Prompt and PowerShell on Windows.

Change directory

The ‘cd’ command cannot work for changing drives in Command Prompt.

Home

We can go to the home directory with ‘~’ symbol in PowerShell.

PowerShell supports a variety of commands that are used on Windows, Linux, and macOS. There are no obstacles to get used to PowerShell. You don’t need to change your habit. PowerShell is similar to Linux Shell but better. I still remember the day that Linux Shell syntax made me a headache. With PowerShell, I can quickly write scripts for Linux and macOS.

PowerShell Tricks

How to show top 5 processes?

How to convert output to CSV and HTML files?

How to modify the suffixes of multiple files? For example, rename all of the .tpl files in the current directory to .json.

How to color the console output?

How to run multiple jobs and check job status?

How to define an array variable?

How to reads a line of input from the console?

Automation Demo: Building Barcode Reader Project

Prerequisites

Basic ideas

  1. Select your operating system.
  2. Get the source code of barcode reader app.
  3. Set the absolute path of your barcode SDK.
  4. Build the project.
  5. Run the app.

Screenshots

Windows

Linux

macOS

Source Code

https://github.com/yushulx/powershell-barcode-autobuild

Originally published at www.codepool.biz on March 26, 2018.

Manager of Dynamsoft Open Source Projects | Tech Lover