simple powershell installation scripts for macos

If you’re playing with Powershell under Mac (see ) you reach a point where you want to quickly install and uninstall Powershell from the command line. Thus, the following two scripts.

First to install;

#!/usr/bin/env bash

file=`ls powershell*`
[ -z "$file" ] && echo "Cannot find powershell installer" || sudo installer -pkg ${file} -target /

Then to uninstall;

#!/usr/bin/env bash

sudo rm -rf /usr/local/bin/powershell /usr/local/microsoft/powershell

You can name these whatever you want (I chose and respectively) and remember to set their permissions respectively. Make sure the install script is in the same directory with the the Powershell dmg file, otherwise you can run the uninstall script from anywhere.