Fun with PowerShell, Azure Automation and Microsoft Teams

I’m currently working on a solution at work which is ultimately a contribution to our process of trying to keep on top of our proof of concept environments usage of networking and in particular ip address ranges. We have a rolling set of Azure Virtual Networks that vary in size from a class C to the occasional class A when we have a silly scale HPC or Kubernetes CNI requirement for a gazillion addresses in a big subnet.

The solution is coming together in very small building blocks and this post is to provide me (and you interwebs folks) with a reference to the filter syntax for List all teams in Microsoft Teams using Microsoft Graph.

Although the automation method shouldn’t really matter for what is effectively a big REST API, you know how it is when you have to translate syntax and fiddle around with quotation marks and things. Anyway, to cut a long story short the rough PowerShell script for List all teams in Microsoft Teams in PowerShell is:

# PowerShell to list all teams in your tenant
# Assumes you have set up your certificate authentication
$appId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$tenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$cert = Get-AutomationCertificate -Name 'AzureAutomationCertificate'

# Magic we are doing needs beta apis for the filter to work
Select-MgProfile -Name "beta"

# Authenticate to MS Graph
Connect-MgGraph -ClientID $appId -TenantId $tenantId -Certificate $cert

# Get list of Teams i.e. Groups with the special resource provisioning options set
$teams = Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')"
$teamscount = @($teams).Count
Write-Verbose "The number of teams is $teamscount" -Verbose

# Close Connection to MS Graph
Disconnect-MgGraph

A few caveats and notes

  • This isn’t a full working example, in my case I’m using Azure Automation Runbooks and they are very very particular about their outputs and object handling. I’m still working on my translation.
  • It assumes you have done the work to create a self-signed certificate, create the app registration, uploaded the certificate to the app registration *and* set it up in your automation account. (I might do a meta post on this as I found one blog post that had the wrong parameters for the cert generation and generated a cert file of format cer with a pfx extension…)
  • This is being written for an Azure Automation Account in PowerShell, remember to add the relevant modules that are needed. I was adding individual modules as I found them first but you will probably be quicker just using Microsoft.Graph – you will find it in the gallery. Otherwise for the above you will need Microsoft.Graph.Authentication, and Microsoft.Graph.Groups.
  • If your tenant is anything like ours then you will always get 100 as the count of teams, due to the way that the apis manage their output length.
  • The script doesn’t do anything useful but I thought it might help to see the filter syntax

References, Source Material and Inspiration

How life goes in circles

That a significant pointer would be found in a response on GitHub by Darrel Miller is quite fascinating. I met Darrel on the expo floor at Microsoft Ignite in Orlando in 2018 and only really because I was after some “Swag” and had to get a card stamped by various Product Managers and Architects on the Microsoft 365 stand. At the time I was up to my neck in Azure and trying my best to get away from SharePoint (and Microsoft 365) and my discussions with the people on those stands were all to try and get me to talk to Graph and get back in to SharePoint Development with the new SPFx thing.

So it’s taken me about 2 and a half years, but I’m finally getting there. Thankyou Darrel – check him out on twitter etc!

Passed SC-300: Microsoft Identity and Access Administrator

I’m pleased to say that I recently passed Microsoft Exam SC-300 : Microsoft Identity and Access Administrator and as a result gained Microsoft Certified: Identity and Access Administrator Associate. I think this might be my first single-exam associate certification as all of the rest (including data platform last month) have all been the older style two exam format.

Badge describing Microsoft Certified Identity and Access Administrator
Microsoft Certified Identity and Access Administrator Badge

If this exam is anything to go by then the new set of Security and Compliance Microsoft Exams are a good move to recognise that Microsoft Cloud Architecture needs an understanding of how Azure and Microsoft 365 work together. Unfortunately I still see Enterprises having to remediate choices that came about as a result of Identity being implemented for a workload, then being overtaken as accidental conflicts come about due to narrow assumptions. That said, cloud has a habit of compressing things together as the Cloud Service Provider takes over the roles that had to be undertaken for on-premises!

Passed DP-900: Microsoft Azure Fundamentals

I’m pleased to say that I recently passed DP-900: Microsoft Azure Fundamentals. If you’ve come to this post via the home page then you’ll see that I recently passed DP-200 and DP-201 to achieve the Certified Data Engineer certification and as I had a discount voucher with 50% off an exam I decided to do another fundamentals exam.

Microsoft Certified: Azure Data Fundamentals
DP-900 Badge

Although my employer hadn’t asked, I decided to go for the set as a qualification for the Microsoft Partner Data Platform Competency. It appears that Microsoft are shifting away from the technical assessments that were delivered through partner university. This makes a bit of sense now that there are obvious public certifications available and while being a little more difficult, the fundamentals is more of a useful achievement.

From a personal milestone this is my 40th Microsoft Exam pass; way back before OneNote was a thing I started an exam ritual of creating a folder for the next exam I was targeting. In the small development company that was the first Microsoft Partner I worked at we used presentation binders for training packs – basically a ring binder with pockets in the front and spine for labelling. I would go through the ritual of creating a front cover for the binder, with my name, exam and “volume” number. I still go through this exercise and they have slowly counted up over the last year and a bit. Now my “exam process” tends to focus around OneNote but I still have a set of pipeline folders which have files related to an exam prep.

Microsoft Certification as a thing has ebbed and flowed through the years. Like a lot of things early in my career I just simply something because my employer asked me to. They wanted to get Microsoft Gold Partner and needed employees who had certifications. Thus started my journey with my first exam pass on April 19th 1996 which at the time of me writing this post is 25 years ago. That was also just under a year before I got married, so my long suffering wife has been with me for my entire certification journey!

Passed DP-201 Designing an Azure Data Solution

I’m pleased to say that I recently passed DP-201: Designing an Azure Data Solution. I did this a week after the DP-200 exam and gained my Microsoft Certified: Azure Data Engineer Associate Certification as a result.

As I mentioned in my post about DP-200 the learning paths are identical on the exam pages for DP-200 and DP-201 but one thing I discovered after DP-200 is that the certification page has additional learning paths which were helpful in augmenting my knowledge.

I found the exam slightly easier going and the score (which means little) was higher than I received for my DP-200 pass. I think this is fair on a number of levels, I don’t work with Azure Data every day so implementation was always going to be tougher.

Passed DP-200 Implementing an Azure Data Solution

I’m pleased to say that I recently passed Microsoft Exam DP-200: Implementing an Azure Data Solution. Although a new single exam is in the wings, I was ready to progress and had read that one benefit of the “current” Data Engineering Associate exams was that the renewal would still be 2 years rather than the new style of one.

As you’ll read on I sat DP-201 the week after this exam. Having reviewed the material available it was the same on Microsoft Learn so there was little more to be gained in the time.

For DP-200 I used Scott Duffy’s course on udemy and the learning paths featured on the exam page.

I found the exam fairly tough and of the three I did together it was the hardest, fairly I think.

YouTube Pandemic Comfort

This is a bit of a random frivolous post but as I’ve heard from one or two others, “random” YouTube channels have been a bit of a comfort or relief during the more intense moments during the rolling lockdowns that have been necessary during the last few months.

I’m amazed at how some have managed to continue to create content during these tricky times and others have understandably been a bit quiet while (I hope and assume) the content creators focus on more important things in life than indulging strangers.

Channels where I watch Everything

Audiology Associates UK – This is one of the few channels that I watch every video posted. It’s a channel from a practice in South Wales; an area I am quite fond of between work and Motorcycling – Off Road Skills have been based there for years and are a group of thoroughly good people. And yes, it’s a bit of an indulgence being that it is almost entirely videos of ear wax removal (which raises an ewww yuck from Mrs L).

Matt’s Off Road Recovery – This is a video channel of a family Off Road Recovery business based in Southern Utah. Like Audiology Associates I watch every video they post from the engineering work on their new recovery truck (an old corvair) to a lot of tourists and Razer drivers stuck in various types of sand or sometimes snow. Although we get a decent amount of snow in the UK and Scotland we don’t have snow apart from on a few beaches – certainly no desert conditions. As with most of the other channels I like, Matt and the rest of the team are informal and down to earth but are continually problem solving in their specialist area. It’s got quite a charm and in a way reminded me of the ensemble cast in an American Sit Com – it doesn’t play for laughs but holds together really well around Matt.

Regular Watches

These are channels where I watch regularly but perhaps not everything. For instance the depth of material or length may need more attention or focus, meaning that I can’t multitask or my attention span needs to be longer.

Bjørn Nyland – Bjørn is a “YouTuber” from Norway who has a channel that focusses on Electric Vehicles but isn’t afraid of straying on to sustainable transportation and basically following his curiosity. He is very productive so I dip in from time to time to see what he has reviewed (he and Norway seem to get every new EV going) and to see how Volkswagen are doing against the other manufacturers and whether it is time for me to commit to an EV. He is very methodical which means his content can be quite detailed which is a good thing.

Misha Charoudin – Misha used to work at Rimac Automobili and followed his passion to work at apex nürburg doing a bunch of “stuff”. With the owner at apex he delivers a spectrum of content around the Nordschleife and I particularly like the mix of material which is delivered in an open and informal way. I particularly like the way that they share the basics of running a rental and experience business and how they balance operations with giving a good experience for customers.

The Hoof GP – A chap based in Dumfries and Galloway that trims cow hooves and does his bit to share cattle husbandry. A compelling watch like the ear wax removal videos – and another cheerful but serious presentation style.

Corridor Crew – A production crew based out of California, I particularly like their Stuntmen React videos. This is quite unusual for me as I generally don’t like the reaction format but they manage to balance the dynamic and more importantly get practitioners that are eloquent and passionate about their profession. The amount of effort and work involved in “entertainment” is amazing. Their content has a great amount of depth and I dip in to this when I have the mental bandwidth.

Occasional Watches

These are channels I subscribe to and check regularly but don’t necessarily watch everything.

Robert Mitchell – Robert is the owner at “Apex” and although I don’t watch his material as much as Misha above, for completeness include it here.

James Hoffman – If you like or are interested in Coffee then subscribe to James Hoffman. In a way my viewing habits are a victim of James’ success. The coffee brewer, grinder and anti-static grinding “hack” I use almost every day are straight from his videos. Unfortunately now that I have a process that works for me and with coffee from a local, Scottish roaster I find myself watching less as it is all working!

I don’t subscribe but…

Artisan Electrics – I stumbled across this because it featured a number of installs of electric charging. As well as the EV Charging posts I really enjoy the problem solving videos which show the benefit of having a sound methodology.

Bigclivedotcom – what’s there not to like about a channel featuring a Scottish Chap with a goatie beard ? This is a highly detailed and educational channel about electronics, which generally involves pulling cheap electronics apart and uncovering the odd horror or pleasant surprise. Oh and trimming tips with funnels.

post 10 – not a lot to say about this channel but it includes a number of fascinating videos of drains being cleared of leaves and other debris with a rake. Strangely compelling at times.

Passed AZ-400 Designing and Implementing Microsoft DevOps Solutions

I’m delighted to say that I passed AZ-400 Designing and Implementing Microsoft DevOps Solutions on Monday November 23rd 2020. After MS-500 this was “fun” if such a thing can be said about a Microsoft Exam.

To prepare I did things quite informally in that I didn’t spend any money on courses or test exams but spent the time to do every learning path from the list on the syllabus page and the additional learning paths from the featured training for AZ-400 on the Microsoft Partner training page.

My method is to create a OneNote section for each exam I target and then I create lists of links to training along with an estimate of how long the training says it will take. The handy thing about the learning paths and profile page is that it counts down as you complete sections, meaning that it feels like you are making progress. When I feel I am on the home stretch I book the exam with however long I feel like I need. With this exam I’ve had the benefit this year of supporting an iOS mobile application development project on the Microsoft Platform which really helped me to understand the build and distribution aspects of that.

I make sure that I do every exercise I can and it was excellent to see how good GitHub is – I’m quite old and have worked with Microsoft technologies since Visual SourceSafe and before the Microsoft acquisition of GitHub. The training that the latter offers is really really good for a free to use resource.

Other than that my take on the exam is that it is a wide ranging topic so the exam is basically DevOps where one part of the solution is a Microsoft product. This means it pivots – you won’t necessarily be using a “Microsoft” build solution like Azure DevOps or GitHub to build your solution if you are developing in Visual Studio and so on.

I enjoyed the training for this exam as it is heavy on automation but also straight forward to follow along with the setup I have. I’m fortunate to have an Visual Studio subscription allocated to me as part of working for a Microsoft Partner and the tooling and Azure Subscription that come with this was essential in completing a number of the exercises on Microsoft Learn as you follow along in VS Code, GitHub, Azure DevOps and Azure in building solutions.

Certification Badge for Microsoft Certified DevOps Engineer Expert
Microsoft Certified DevOps Engineer Expert

I’m up to date with my other Azure Exams so I also achieved an Expert Certification with this pass which is a nice feeling!

Speed up your DNS in the UK – really ?

Being male I’m probably obsessed with fiddling when I could probably spend my time doing something productive. One obsession is tuning (I spent more than the value of my first car on “performance parts”) which I’ve slowly cured over the years and now refuse to modify my cars.

Funnily enough one thing that has made a real difference to my internet performance now that I have broadband is to ignore the popular opinion on websites and actually benchmark my home dns performance and then stick to it.

In my case I’m fortunate to have a decent router that has a caching dns service (rather than simple pass through) and I’ve set this to query the fastest dns server I can get to on my connection. All connections on my LAN point to the dns server on my router by getting the settings through DHCP.

Rather than blindly pointing to Google or Cloudflare, please benchmark your performance by using a DNS performance tool. As I’m very old I like to use GRC’s DNS Benchmark. Yes I’m a Windows user so I probably excluded a bunch of readers but for the rest of us it is a simple .exe and creates an INI file (remember those?) when you create a custom resolvers list.

If you are like me and don’t live in the US then run the program (this is what apps used to be called) and create a custom resolver list, then run a benchmark and adjust your network.

Read and weep – in my case Cloudflare takes ten times as long to resolve an cached dns lookup as my router and Google thirty times as long. Unfortunately the cliche is that the fastest dns is that provided by the vendor of my connection. Your mileage may vary, which is why you should test.

Now to deal with the challenge of dns settings when you have failover between two ISPs!

Microsoft Security Exam Passes

I’m delighted to say I just passed Exam MS-500: Microsoft 365 Security Administration in my first exam since Covid-19 lockdown in the UK and my first “online” exam that I sat at home. This was my 36th Microsoft Exam pass and all of the other 40odd attempts I’ve had (mostly passes) sitting exams have been in a variety of test centres around Edinburgh and the Central belt of Scotland.

I think I also forgot to mention my pass of Exam AZ-500: Microsoft Azure Security Technologies in February 2020 too. At work we had a push for the security competency and even after the requisite number of other folks had the pass I stuck at it.

My Third EV Drive (Polestar 2)

If you’ve seen an earlier post on the blog you will have seen that I hired a Tesla Model S for a long weekend in March 2020 and had a great time in what seems to be a different era as it happened just before responses to Covid-19 kicked in and holidays got cancelled.

I recently drove my third EV ever (the first had two wheels and was a BMW) when Polestar unexpectedly brought their test drive programme to Scotland and to a location only about an hour’s drive away from where I live.

More details to come but we drove the Performance Pack version and it was awesome. Different feel to the Tesla S due to the way the interior is organised. An excellent vehicle and I’d definitely consider it for a longer evaluation.

Polestar 2 Performance Pack