June update 1 – Visual Studio Code and debugging

Starting with something new on my blog!

I notice that my work is increasingly focusing on a smaller topic (PowerShell) and that I have less to blog about.

I miss blogging, so I came up with the monthly updates.
In these updates I want to give an insight into my work & share what I did and learned that day, and what struggles I encountered.

I’ve done it below for last week, but in the middle of the week I already noticed that I wouldn’t keep this up like this. So, it went from Weekly- to Monthly- updates. The daily updates as below will not be in the next update.

And of course I can get new inspiration from these posts to blog about, because I will keep better track of what I do per day! Win-win?


What happened this week?

We work with the Agile method in our team. A few weeks ago we received a training about Agile training and there we learned that we should focus even more on working together per PBI, and not that everyone has their own PBI within the sprint.

This week we started a pilot to focus more on collaboration. Very fun and educational, although it didn’t run like a well-oiled machine yet, we did share more knowledge with each other this week that we didn’t know the other knew.

This week was mainly focuses on Visual Studio Code and debugging (coincidence), how do I deal with debugging and how does the other person deal with debugging?

At Wortell we offer customers the modern workplace. This is a combination of different products, including Intune, etc. What ultimately matters is that the end user has a device that he can use wherever he wants.

The workspace is installed using PowerShell. Keeping the settings updated is also done by Wortell. To keep the workplace up to date with the standard, we use Configuration Drift. We compare the templates, exceptions, and tenant settings and make changes where necessary.

We are currently working hard to update the Configuration Drift.


Monday

Monday was a collaboration day where we wanted to standardize the Configuration Drift a bit more for the modern workplace.
What exactly do we want to do, how do we do this, and how do we continue with this in the future?

What we mainly found out was that it was not yet standardized per component within the modules, so we now adjust a small part per component to make it equal. To work more agile, we work via vertical slicing and we work on a small part of code at a time to be able to oversee what we are adjusting.

And I also learned something new in debugging on Monday. Did you know that you can put the breakpoint in a new place and that this already works DURING the debugging? So suppose you have to press F11 too often to get where you want, you can also just set the breakpoint again.


Tuesday

On Tuesday I continued to bring the Configuration Drift to a standard. I mainly focused on part of the code that I created.

In addition, today I ran into another bug in one of my cmdlets. With Get-StorageBlob I retrieve the files from an Azure Storage Blob. Sometimes the BOM characters are passed in the bytes so I can’t convert it to json format anymore.

My knowledge is nil in this area, and after endless Googling I solved it with a hobby solution with a regex, a hardcoded, and an extra replace just to be sure.

if ($Return.GetType().Name -eq 'String') {
    $Return = $Return -Replace '\xEF\xBB\xBF', '' 
    $Return = ($Return).replace('', '').Replace('ÿþ', '')
    $Return = ($Return).replace('\xEF\xBB\xBF', '')
}

it looks like sh*t in the code itself, but hey, it works. Luckily I have a colleague who can take a look next week & solve this.


Wednesday

On Wednesday we had the product day. On this day, different developer teams come together and we look at new features and share knowledge with each other.

And we ended the day with a beer and a barbecue.

And sh*t, I found out that Tuesday’s fix only works in PowerShell version 7 and above. So, now I have to find out if we really aren’t using a lower version somewhere.


Thursday

I managed to persuade my colleagues to start using my Optimized.Mga module by showing what the Batch-Mga cmdlet can do.

We will use this as a pilot in a component of Configuration Drift.

This day was the day that I had the greatest shock of the week.

My colleagues don’t like this, but I’m working with the git GUI in Visual studio code and instead of pressing the stage all changes button, I pressed the discard all changes button.

Visual Studio Code and debugging

Which means all your current changes will be reverted. Big shock this morning, but a few search terms later I found out that Visual Studio Code maintains a local file history management and luckily I was able to update the files back to the most current status.

You can do this with Ctrl + Shift + P and type in Local History, this will show you the options you have for the Local History.

Visual Studio Code and debugging

Friday

Today I was finally able to continue with Configuration Drift.
Lots of debugging in VSC.

Did you know that you can also edit breakpoints that they only trigger on an expression in Visual Studio Code?
Super handy for when you only want to start testing at a certain value without having to adjust your code yourself (taught a colleague).

Right click the Breakpoint and click on Edit Breakpoint.

Visual Studio Code and debugging

Now add the expression you’d like the debugger to stop on. This can be a count, a variable, or whatever.

Visual Studio Code and debugging

Summary of what I learned this week

I have new items for blog posts! See the points below, you can expect these in the near future!

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell DevOps Engineer. In my spare time I write about interesting stuff that I encounter during my work.

Leave a Reply

Your email address will not be published. Required fields are marked *