As you might be aware, nowadays we see more and more AI generated content and helpers. Microsoft often calls those Copilot. There are a fair number of those out there already. One of those is the copilot for helping to write code through GitHub. It is not just to write code, it can also be used to get ideas, give suggestions for optimization, code checking, but also trying to help you understand what a certain piece of code does in the first place (especially when somebody FORGOT to write enough comments in the code to explain what it does).
Now, we can use this GitHub copilot as well in Visual Studio and Visual Studio Code as an extension plugin. We can use GitHub copilot and GitHub copilot chat extensions to aid us in our work while developing code, writing scripts, or tying to figure it out, or while learning to code. The story about how to get it and what it does can be found here: About the GitHub Copilot extension for Visual Studio – Visual Studio (Windows) | Microsoft Learn .
I have created a little demo, because I had to create a little piece of code to put in a script dealing with SCOM agents. The script itself just removes a very old SCOM agent and installs a newer one. However, we found that in rare cases the uninstaller can remove a DLL which can be shared by other applications and for some reason simply removes it and breaks the other application. Thus, we need a simple piece of code to check if the DLL is there and make a backup. And after we run the main script pieces it can come back and check for the DLL and restore it from backup if it got removed.
I figured it is a simple case to make a short demo while writing it.
We use comments in the PowerShell script to first figure out what I want to do. Next, I let the copilot help me with suggestions on how to create the pieces of code belonging to those comments. Of course, there are many more possibilities here and this copilot can go further than these few short pieces of code.
Above is the video of the short example.
I think this is a great use of AI possibilities to help move passed the easier bits and writing repeating code or the easy things which will mess you up by forgetting some bracket or quote. We can focus more and more on what a script or code should do and the logic and how we form the actual functionality.