Migrating from PowerShell ISE to Visual Studio Code

In this blog post I’ll share a number of resources for how to move from the PowerShell ISE to Visual Studio Code for writing and executing PowerShell scripts.

See the source image

Background

Much of the content from this post is sourced from two other excellent resources:

In my working with various customers many times we are working on PowerShell scripts together.  I’ve noticed that many are still using the PowerShell ISE as their primary host for developing and executing PowerShell snippets or scripts.  Back in May 2017 the PowerShell team announced the shift of focus from PowerShell ISE to Visual Studio Code with the Announcing PowerShell for Visual Studio Code 1.0! blog post.  Combining the move to PowerShell Core (v6) (based on .Net Core which is cross-platform) with the limitation that the PowerShell ISE is Windows-only meant a change in direction was needed.

In the following sections I’ll overview a number of steps for getting up and running with PowerShell in Visual Studio Code.

Visual Studio Code

The first step is to install Visual Studio Code.  If you’ve feared it because it has the words “Visual Studio” in the name don’t worry.  Visual Studio Code is really a text editor (think Notepad) with really powerful extensions that you can add.  I recommend the “user install” vs. “system install” as the former doesn’t require Administrator rights.

PowerShell extension

The next step is to install the PowerShell extension for Visual Studio Code.  This extension provides syntax highlighting, intellisense, running scripts with F8, and more.

One important change to the Visual Studio Code setting that I found especially helpful is keeping the focus on the editor window (not the console) when executing scripts.  Update the following setting to configure this.

"powershell.integratedConsole.focusConsoleOnExecute": false

Shell Launcher extension

If you have a need to regularly switch between multiple shells (PowerShell v5 / v6 / v7-preview, Git Bash, Windows Subsystem for Linux (WSL) Bash, CMD, etc.) like I do the Shell launcher extension is helpful.  Be sure to follow the instructions for setting a keybinding for switching shells (suggested “Ctrl+Shift+T” on Windows).  In my case this keybinding was already used by another extension but I was okay with overwriting that.

PSISEtoVSCode2
Keybinding for Shell Launcher to launch a shell

The following are the settings I use for the multiple shells:

"shellLauncher.shells.windows": [
        {
            "shell""C:\\Program Files\\PowerShell\\6\\pwsh.exe",
            "label""Pwsh Core"
        },
        {
            "shell""C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe",
            "label""PSv7 (preview)"
        },        {
            "shell""C:\\Windows\\System32\\wsl.exe",
            "label""WSL zsh"
        },
        {
            "shell""C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
            "label""PowerShell (v5)"
        },
        {
            "shell""C:\\Windows\\System32\\cmd.exe",
            "label""cmd"
        },
        {
            "shell""C:\\Program Files\\Git\\bin\\bash.exe",
            "label""Git bash"
        },
        {
            "shell""C:\\Windows\\System32\\bash.exe",
            "label""WSL Bash"
        }
    ],

 

Bonus – ZSH and auto-suggest

I’ll be the first to admit that I don’t use Windows Subsystem for Linux (WSL) often.  That said there are times I find it helpful to run the Azure CLI on a WSL shell though.  An example is when I’m doing demos or presentations and I want to showcase the auto-suggest feature in Zsh (short for “Z shell”).  Not only does the auto-suggest help me remember what commands to type but it lets the audience follow along more easily.  See the following links for installing and configuring.

 

PSISEtoVSCode1
Example Zsh auto-suggest with Azure CLI

Conclusion

In this article I walked through a number of useful extensions or configurations to help migrate from the Windows-only PowerShell ISE to the cross-platform Visual Studio Code.  If you have additional suggestions or tips please share them in the comments.

-Frog Out

How To Add PowerShell v7 Preview to the New Windows Terminal

In this quick post I’ll show you how to add PowerShell v7 preview 1 to the new Windows Terminal.

Background

The new Windows Terminal was announced at Build this year and has been available (building from source code yourself) through the Microsoft/Terminal GitHub repo.  A very early preview of the Windows Terminal is now available through the Microsoft Store (link).  I haven’t verified but I believe you’ll need a few prerequisites in order to install.  Out of the box the current preview of Windows Terminal offers:

  • PowerShell Core (v6)
  • Windows PowerShell (v5)
  • CMD (command prompt)
  • WSL (Windows Sub-system for Linux, legacy console)

Solution

After installing the Windows Terminal from the Microsoft Store, open the Settings from the dropdown menu (or click “Ctrl + ,”).

Find the “profiles” element in the settings file and add the following JSON snippet to the array.  Verify the “commandline” and “icon” locations match where PowerShell v7 preview 1 is installed on your machine.

{
"acrylicOpacity" : 0.5,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "C:\\Program Files\\PowerShell\\7-preview\\pwsh.exe",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{90cbdc15-f4fe-49d2-a245-ec066b70845f}",
"historySize" : 9001,
"icon" : "C:\\Program Files\\PowerShell\\7-preview\\assets\\Powershell_av_colors.ico",
"name" : "PowerShell 7 preview",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : false
}

Here is a link to my complete profiles.json for comparison.

After you’ve added the above element you’ll now see PowerShell v7 Preview in your dropdown list of available shells with the proper icon.  For an added bonus I also added Zsh (with the Oh My Zsh framework for auto-suggestions and more) based on seeing demos from Jeff Hollan showcasing that shell.

WT PS v7 preview-1

Below screenshot shows PowerShell v7 Preview in use and verifying the PSVersion.

WT PS v7 preview-2

Conclusion

I’m very excited to begin using the Windows Terminal more in my daily tasks.  Being able to switch back and forth between multiple shells (specifically PowerShell v5 and v6/v7) is possible in Visual Studio Code but this will be a much easier solution for many of my scenarios.  Hopefully someone else will find this helpful as well.

 

-Frog Out

PowerShell Script to Find Connectors from PowerApps Apps

In this post I’ll share a script I developed for a customer to find which connectors are used by which PowerApps apps.  Currently this is not something available through the Power Platform Admin Center.  Feel free to use this script as you see fit.  This script is provided as-is without any warranties of any kind.  If you update or adapt it and decide to re-post please provide attribution.

Script

Note: If you do not see the below Gist please refer to code at this location: PS-Get_PowerApps_App_Connections.ps1

Sample output

image.png

You may notice that the output contains a complex property for the Connections.  It has been some time since I worked with formatting output in PowerShell.  If you have an improvement to the formatting please share back suggestion and I’ll update the sample script.

-Frog Out

Wrap Up from Microsoft Ignite 2015

   This was the first year of the Microsoft Ignite conference which merged a number of previous conferences including TechEd, SharePoint Conference, Project Conference, and more.  With over 23,000 attendees, a new venue, and numerous Microsoft senior leadership and product group in attendance (including CEO Satya Nadella himself) this was definitely a huge event.  Rather than re-capping the event itself I wanted to take a minute to mention a few items that I heard / saw at the conference.  I am still downloading and viewing a number of sessions that I couldn’t attend (same time as another session or room was at capacity) but these are highlights that I wanted to share with others.

 

Recap

  • No “internal” FIM in SharePoint 2016 – SharePoint 2016 will not ship with a version of the Forefront Identity Manager product included.  This is a fairly big deal for any customers that are using the “SharePoint Synchronization” option (allows for import and export of content to / from SharePoint) for the User Profile Sync in 2010 or 2013.  Your options in 2016 will be the Active Directory Import (same as 2007 and re-introduced in 2013) or “external” FIM which is installed and managed outside of SharePoint Server.  See the following resources for more details and how to install FIM 2010 R2 + SP1 with SharePoint 2013 so that you can start planning today if you do need the full features of syncing data into and out of SharePoint.

What’s New for IT Professionals in SharePoint Server 2016 (session recording with announcement)

Configuring SharePoint 2013 for the Forefront Identity Manager 2010 R2 Service Pack 1 Portal (install overview)

  • Project Siena – Project Siena looks like a viable alternative (not replacement) for many (smaller) custom development scenarios.  Essentially it is an app that lets you build other apps.  I do not see this replacing InfoPath, Lightswitch, and half a dozen other technologies that have popped up over the past few years but I do see a promising future for this technology (HTML5 + JS based, similar to many other tech stacks that Microsoft is promoting).  Note that it is still in a beta release last time I checked but the fact that it caters to the Excel power user with similar syntax merged with an easy drag and drop interface feels like this could gain traction better than some other tools.  If you aren’t familiar with Project Siena you really need to see it to understand it.

Microsoft Project Siena: Build Apps and Create New Mobile Solutions (session recording with demos)

Microsoft Project Siena (Beta) (product site)

  • New SharePoint hybrid search option – Hybrid search is receiving a huge update / upgrade later this year.  In it’s current (May 2015) form SharePoint hybrid search involves separate search service applications / indices for on-prem farms and Office 365 / SharePoint Online.  If you query one source you can federate the query to the other and get results in a separate result block.  The problem though is that configuration can be fairly complex, search results aren’t integrated (in-line with each other), and you likely have a large number of servers on-prem for the search service.  Later this year (target timeframe, subject to change) Microsoft will release an update which will allow an on-prem “cloud search service application” to crawl and parse content but then push the metadata up to Office 365 for indexing, querying, etc.  The massive benefit of this is that your on-prem content will then be able to be used in other services like Delve, Office 365 data loss prevention (DLP), and others that currently have no expected on-prem release (or won’t be supported until future releases of SharePoint). Additionally you will need a much smaller on-prem server footprint to support search (the example given was going from 10+ search servers down to 2).  This is a big win in my opinion and I can’t want to test it out when it is released.

Implementing Next Generation SharePoint Hybrid Search with the Cloud Search Service Application (session recording)

  • Nano Server – Nano Server is a new installation option for Windows Server 10 (Server 2016 or whatever the final name ends up as) akin to Server Core in the past.  There were a number of sessions that talked about how small the footprint of Nano Server will be (400MB, yes MB compared to 8+ GB of server + GUI “full” edition).  The changes that this introduces not only affect performance but also re-architecting tools to work remotely (there is no local logon or UI for Nano Server, everything must be done remotely).  Things like Event Viewer, Task Manager, Local Services, etc. can be accessed remotely in a web UI similar to the “new” Azure Portal UI (super slick, take a look).  This may sound scary to some admins who are used to having RDP or locally logging on to a server but listen to Jeffrey Snover’s take on this.  We are IT Professionals and this is a technology that will reduce number of reboots, make servers more secure, reduce infrastructure footprint, and have numerous other benefits.  You owe it to yourself and your company to learn about this and see if it will work for the services you provide.

Nano Server (session recording)

Nano Server: The Future of Windows Server Starts Now (session recording)

Remotely Managing Nano Server (session recording)

  • PowerShell – Getting to see Jeffrey Snover (inventor or PowerShell) and Don Jones (first follower of PowerShell, see the link in slide deck) geek out about PowerShell was one of the best sessions I got to see at Ignite.  Hard to describe in words hence I recommend go watch the recording.  Jeffrey had some great advice about using PowerShell as a tool to explore and dive into problems or scenarios you are trying to solve.  That sense of adventure can be a motivating force for your personal and professional careers.  It was really inspiring and I love the fact that Jeffrey (and Don’s) mindset is spreading to so many others these days.

Windows PowerShell Unplugged with Jeffrey Snover (session recording)

 

   On a side note I also wanted to mention one of the obvious but not always talked about benefits of going to a conference like this in-person.  During the week I was able to introduce myself to a number of presenters that I had previously not met.  Some were MVPs, fellow Premier Field Engineers (PFEs), product group members, and more.  The connections you make can last for years and provide an invaluable network for sharing information and getting assistance when you are in need.  I even got a PowerShell sticker directly from Jeffrey Snover himself (another personal highlight).

WP_20150511_001

 

Conclusion

   This is just a short list of some of the sessions that I attended along with highlights or key points that I wanted to share.  If I find anything else significant from the recordings I am going back to watch I’ll update this post.  For now though go check out the recordings above or the hundreds of other ones that are up on Channel 9.  I encourage you to attend next year when Ignite 2016 will be in Chicago again May 9-13.

 

      -Frog Out

Slides and Scripts from DogFood Conference 2014

   I was pleased to once again speak at the Dog Food Conference here in Columbus, OH.  I believe this is the 3rd year that I have spoken and the 4th or 5th year that I have attended.  The venue has moved to a more spacious location which definitely helped with giving attendees, speakers, and vendors more room to spread out,  I was especially happy to meet up with dozens of previous customers and co-workers at the conference.  This really is a great mix of audiences (developers, IT pros, and business users), customer segments, and topics (SharePoint, .Net, PowerShell, BI, ALM, and more).

   Thanks to everyone who attended my session at the very end of the last day of the conference.  We had a number of good side discussions and questions throughout the presentation.  Below are my slides and scripts.

 

Demo PowerShell Scripts

 

Slidedeck

 

      -Frog Out

Slides and Scripts from SharePoint Cincy 2014

   I was pleased to present at SharePoint Cincy again for the third year.  Geoff and all the organizers do a great job.  My presentation this year was “PowerShell for Your SharePoint Tool Belt”.  Below are my slides and demo scripts.  Thanks for all who attended, I hope you found something that will be useful for you in your work.

 

Demo PowerShell Scripts

 

Slidedeck

 

      -Frog Out