Skip to main content

Posts

No subscription found in the context.

FRUSTRATION!!! Don’t you just love it when you change nothing and then something breaks?   Working with VSCode and Azure, I do a lot of Infrastructure as Code.   I love the idea of being able to write code that builds exactly what I want, every time.   The problem is that on occasion, things change outside the scope of my code and now I am trying to solve a mystery.   The latest one involves whenever I run a simple Azure command.   For exam, Get-AZVM . This should not be hard.   Well, here is the result in VSCode. No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Connect-AzAccount to login So, I execute : Connect-AzAccount When you do this, it brings us to a website to go to and a code to enter. PS C : \ Connect-AzAccount WARNING : To sign in , use a web browser to open the page https : //microsoft.com/devicelogin and enter the code FNTC88YR4 to authenticate. Onc
Recent posts

Registering an Azure Resource Provider with PowerShell

Azure seems to be the cloud that just keeps building and building. Resource providers allow Azure to provide services.  For example, virtual machines utilize the Microsoft.Compute  resource provider to provide services to Azure so you can have a virtual machine.  Checkout this article to see what the Microsoft.Compute exposes to Azure:  https://docs.microsoft.com/en-us/azure/role-based-access-control/resource-provider-operations#microsoftcompute It is not that exciting to look at.  What is exciting is what resource providers can do.  Azure acts as an orchestrator.  The resource providers tell Azure what they can do and they perform all the work.  Each resource must be registered with the subscription before Azure can utilize them.  Just remember that you cannot unregister a resource provider if any Azure asset in your subscription is using it. (Note: The following assumes that you are using VSCode and are logged into your Azure subscription. Our goal is to register the Micros

My Advanced PowerShell Class has just been updated!

First of all, thank you to my fellow presenters at PowerShell Conference Asia 2019.  All of you really helped me to update the content of my advanced PowerShell class.  Content will be delivered in PowerShell 7.  We will be addressing compatibility with your pre-exiting scripts when running in PSv7 as well as providing a few new tricks. As you can see, I am also adding in content on some of the experimental features that I think are going to be a hit.  If you are interested, drop me an email and I'll help get you into a physical class or join me on an online class.

My VSCode Configuration for PowerShell

Two weeks ago, I had the honor of delivering a workshop at PowerShell Conference Asia in Bangalore.   My workshop was called Zero to Hero where I taught the fundamentals of PowerShell with the goal of allowing the conference attendees to have the confidence to attend the rest of the high-level sessions.   It was a success!   With 60 PowerShell enthusiasts enrolled, the organizers had to close registration. I made the decision to utilize VSCode as our scripting platform to get the attendees on the path from the ISE to VSCode.   One of the first questions given to the PowerShell team members at the conference was “Will there be an ISE for PowerShell 7”.   Their answer, “No”.   I also made the decision to deliver the class using the just released PowerShell 7-Preview 4.   This version addressed several issues that I had with Preview 1-3.   It is not perfect, but it is now at the performance and reliability level that I want and I am teaching it in my Windows PowerShell c

The Return of Out-GridView

Yes, our beloved cmdlet Out-GridView has been returned to us!   The original Out-Gridview was an easy and convenient way to quickly create GUI output and to accept limited input. In PowerShell Core (PSv6) we lost our beloved cmdlet.   Well, it is back! For these demonstrations I am utilizing PowerShell 7-Preview 4. Out-Gridview is actually being provided as a module.  Execute the code below to install it.  Out-GridView still works the same as it did before. Let’s take a look at a few of the features and what is new with Out-GridView.  The Quick Serach field works the same at the Filter field in the Windows PowerShell version of Out-Gridview.  Type something and if what you type appears in any of the objects property. Here is something new.  It involves the filtering capability.  Once you build a filter, click the Show Code button. You can now have Out-GridView to create the filter it is using in code so you can copy it and past

How to Create and Use a Multi-Dimensional Array with PowerShell

An array is a neat little data structure that allows you to store more than one piece of information in a single variable.   Take a look at the examples below. $VariableName 10 In this example, we have a standard variable.   It contains only one value. PS C:\> $VariableName 10 An array is a bit different.   It stores each value in a unique index number. $Array1 0 Apple 1 Pear 2 Plum PS C:\> $array1 Apple Pear Plum PS C:\> $array1[1] Pear A multidimensional array is like a grid (2 dimensional) or a cube (3 dimensional).   You can add more dimensions but those beyond 3 are hard to conceptualize.   $Array2 0 1 2 0 Dog Alpha 100 1 Cat Bravo 200 2 Bird Charlie 300 Take a