Sign in to follow this  
Jonathan Arnold

Powershell without the Windows headache

Recommended Posts

At LM we are issued MacBooks and support gets a few VM's (Windows and Linux) so we can test new features and replicate bugs that customers come to us with.
But with taking an interest in Powershell it was getting tiresome remoting into a Windows VM to test a Datasource or API script every time one came in.
Then I heard about Microsofts push to release Powershell on GitHub,  I tried the alpha build and had great success and with the beta release of 6.0 they refind the install process so I thought it was time to share my experience.
Disclamier: This version of Powershell for the Mac DOES NOT include some of the Windows only cmdlets (including Get-WIMObject and Hyper-v's Get-VM) so you may not be able to test those but you can still use intellisense to help write the scripts.

The new install process is very easy you just need a terminall session on your MacBook and the latest Mac OSx build of 10.12:
1. We start by installing Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Now we can install Homebrew-Cask so we can install more packages

brew tap caskroom/cask

3. Now for Powershell

brew cask install powershell

Note: The PowerShell formula for Homebrew includes OpenSSL as a dependency. "On macOS, .NET Core requires Homebrew's OpenSSL because the "OpenSSL" system libraries on macOS are not OpenSSL, as Apple deprecated OpenSSL in favor of their own libraries. This requirement is not a hard requirement for all of PowerShell. However, most networking functions (such as Invoke-WebRequest) do require OpenSSL to work properly."
If you would like to install without OpenSSL you will lose some functionality but you can follow the steps here: https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md#macos-1012

When new versions of Powershell are released simply update Homebrew and upgrade PowerShell

brew update
brew reinstall powershell

Note: because of this issue in Cask (https://github.com/caskroom/homebrew-cask/issues/29301), you currently have to do a reinstall to upgrade.

Now with that out of the way we just need a nice place to look at, debug and run Powershell. So VisualStudio Code works very well for this and you can download the Mac version here https://code.visualstudio.com/
Once you have installed this lets open it up and add the Powershell Extension:
1. Open VScode
2. Click the 5th icon on the left side 

Untitled-1.thumb.png.50a61174c1e2afe221b0dade5506f63a.png
3. Search for Powershell and Install the one from Microsoft
4. Once installed click the reload button that replaced install so that the extension loads
5. Now you can open a .ps1 script or create your own!
Feel free to add other scripting languages as well from the massive list of extensions that they haveNow if (for some crazy reason) you need to uninstall Powershell, Homebrew makes that easy as well

brew cask uninstall powershell

Now go have fun and write some cool API or Datasource scripts to share!

Edited by Jonathan Arnold
added tags

Share this post


Link to post
Share on other sites
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this