Thanks to all of the attendees from my Intro to Microsoft Graph Development session from Dog Food Con 2019. I’ve presented here many times and I always enjoy the questions and engagement from local attendees. Below are my slides from the session. Feel free to reach out if you have questions or comments.
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.
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.
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.
The following are the settings I use for the multiple shells:
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.
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.
I have the privilege of presenting “Getting Started with Microsoft Graph Development” at the upcoming Collab365 SharePoint Summit taking place Sept 10-12, 2019. This is a free online conference with MVPs and experts from around the world presenting on developer, IT Pro, and adoption topics.
Title: Getting Started with Microsoft Graph Development
Abstract: “I hear that I need to use Microsoft Graph for developing against Office 365 but I have no clue where to start.” “I want to grant access to company data without throwing in the entire kitchen sink.” Fear not fellow developers and admins.
This session we will ramp you up to a 200 level knowledge on the pertinent parts of Microsoft Graph including endpoints available, syntax, authentication flows, and more. We will also cover useful examples of what can be accomplished using these APIs. Prior experience with Microsoft Graph is not required but can be helpful.
You can also purchase an all-access pass which includes lifetime access to the videos, additional e-books, and more. Looking forward to participating in this great event.
As Registration Chairperson for Stir Trek Conference, this year I was in charge with coming up with a way to print QR code stickers for 2,100+ attendees. The QR codes would contain name and email address for a registered attendee so that sponsors could have a quicker / easier way to capture contact information for giveaway prizes or sending follow up communications. Since we care about attendee privacy we also planned for “opt-out” stickers that could cover over the QR code stickers if attendees chose. In this post I’ll walk through the highlights of how we designed, created, and printed the QR codes stickers.
Designing QR Codes
Before starting this project I was familiar with QR codes, but I never knew the amount of data (or what type) could be encoded in a QR code. Even more interesting (at least to me) is the science behind how to size the QR code relative to the distance at which the QR code will be scanned. The following article is from 2011 but gives some insight into scaling the number of characters encoded with the scanning distance.
We needed to encode attendee first name, last name, and email address. After analyzing our registration data the longest combination of those fields was under 125 characters so we could safely scan a 1″ x 1″ sticker from 6″ away. Since the QR code stickers are put on the attendee badge, the smaller the sticker size the better so that we didn’t take up too much space (or cover the great artwork from Nate Lovett and badge design from Carey Payette).
Since the stickers needed to be 1″ x 1″ I purchased 100 sheets (80 per sheet / 8,000 total) of the following label stickers for less than $20 USD. This allowed for many sample prints to ensure images and other information was lined up on the stickers for the final product.
The stickers came with free downloadable Microsoft Word template for the exact dimensions and layout needed. One wrinkle to the plan was that our shipping vendor (great folks at Markt custom apparel) would be applying the stickers to the badges as they packed attendee boxes. As such we needed to print not only the QR code but also a “verification” sticker with attendee name and registration ID number to ensure the right QR code went to the right box. More on that later using Word’s mail merge to accomplish that challenge.
Generating QR Codes
My primary laptop runs Windows 10 and I was able to find an app in the Microsoft Store called “QR-Code Generator Pro”. There is a QR code bulk creation functionality in the paid “pro” version. I exported our registration data (name + email address) from Eventbrite to a suitable CSV format that this app could then encode.
For many years I’ve “known” about mail merge but I had honestly never used it for more than 5 mins at a time. Working with 2,100+ attendees made mail merge a necessity for the scale and complexity of what I needed. I found the following online article that walks through creating the placeholders in the mail merge template and then linking fields from attendee registration spreadsheet to those placeholders.
2 Ways to Batch Insert Multiple Pictures into Your Word Document via Mail Merge
This took much longer than expected due to the sometimes one-way changes that were applied which required starting over from scratch. I settled on a template that I can now re-use in future years by simply importing the newest attendee data spreadsheet and applying the mail merge. As mentioned previously needing to print not only the QR code but also attendee verification data meant that the “next record” tag had to appear on every other label in the template.
Printing QR Codes
Printing the QR codes on the label stickers took a number of sample runs before I got them working properly. At first the QR codes printed slightly off center. Attempting to adjust the margins on the QR code images proved unsuccessful. In the future I may look at increasing the (pixel) size of the generated QR codes to compensate for the printing issue.
Overall I’m very happy with the final results and the fact that this is a fairly automated and reusable process. As always we’ll continue to tweak and refine the process to continue delivering the best we can for our attendees. If this overview helped save you time, effort, etc. please let me know in the comments or share back improvements.
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)
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.
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.
Below screenshot shows PowerShell v7 Preview in use and verifying the PSVersion.
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.
I was reading a blog post by Mark Heath on This resource group will self destruct in 30 minutes which leverages an open source Azure CLI extension to automatically delete resource groups. This extension accomplishes the deletion by scheduling a logic app in the same resource group. I was curious if I could accomplish the same effect without the need to leverage the Azure CLI (i.e. for any resource group created via portal, PowerShell, etc.) In this post I’ll show how to configure a “self destruct” mechanism using an Azure Alert and a Logic App.
Finalize Logic App – Add JSON schema from alert HTTP request and action to remove resource group to logic app
1) Create Resource Group
If you don’t already have one, create a resource group to host the resources for the self destruct solution.
2) Create Logic App
Create a logic app in the resource group from previous step. Add a trigger for When a HTTP request is received. We will not fill out any of the details for the trigger at this time. Click Save.
3) Activity Log alert
Navigate to Azure Monitor (can search from the top search bar or go through All Services) for the subscription where the solution will be deployed.
Click Alerts on the left hand navigation. Click New Alert Rule.
Define the resource to be monitored:
Signal Type: Activity Log
Monitor Service: Activity Log – Administrative
Signal Name: Create Resource Group (subscriptions/resourceGroups)
Alert Logic – Status: Succeeded
Action Group Name: SelfDestructResourceGroup
Short Name: SelfDestruct
Action Group Action: LogicApp
4) Trigger Alert
Create a new resource group that will then trigger the alert defined in step 3 and consequently fire the HTTP trigger for the logic app defined in step 2.
5) Gather JSON Schema
Navigate to the logic app defined in step 2. Assuming the logic app was successfully triggered, under Run history select the successful logic app execution. On the “logic app run” screen expand the trigger and click on Show raw outputs.
Save this JSON for use in the next step. If you are unable to collect this JSON schema you can use the sample below which is already coverted to the final format needed.
Note: the resoureceGroupName element is buried many levels deep. We will query for this when needed.
The final logic app will look similar to the following:
Test out the solution by adding a new resource group to the monitored subscription. Check the Azure Monitor alerts to see if the Activity Log entry for successful resource group creation triggered the Logic App.
Then verify the logic app execution history shows the resource group deletion was successful.
More than likely you will not want to delete the resource group right after you create it. In that case you can add a Delay action which pauses the logic app for a specified number of minutes (ex. 60 minutes). Additionally you could apply conditional logic to check if the name of the resource group matches (or doesn’t match) a specific pattern. There are many additions you can add to personalize this solution to your needs.
In this post I walked through an adaptation of the Azure CLI extension that Mark Heath linked to. We leveraged an Azure Monitor alert together with a logic app to provide an option to self destruct any resource group no matter where or how it was created. If you have any feedback or additional suggestions feel free to leave them in the comments.
In Linux and Unix there is a “touch” command which will update the timestamp of a file without modifying the contents. You can also create an empty file without having to open an application among other actions. In Windows there isn’t a direct equivalent, but you can get close by using the “copy” command with a “+” at the end of the filename while specifying no destination file. The + symbol points the copy operation back to the source file. This will update the timestamp while not modifying the contents of the file.
This process was helpful for my customer testing out automated CI/CD processes with Azure DevOps and Git. Hopefully this will be useful to someone else. Enjoy.