Background
Being a bit of an insomniac sometimes means that what starts out as a 24 hour day, sometimes turns into a very long day with a period of dark requiring some illumination in the middle. Sadly this is followed by another seemingly endless day before you next have the luxury of some sleep. Stress can be a key factor in prompting this onslaught of being awake and honestly, the combination of a pandemic and the extended period of searching for a new job have likely caused the latest. The fortunate side of being awake has meant that I have had the opportunity to watch a few box sets, so like any other time, I chose a random movie collection to while away the hours and I also decided to write an article for my blog.
When I started blogging, my first idea was to write a series of articles about my transition from scripting in PowerShell to developing PowerShell Modules. During my research for part two in the series, compiling a list of resources that have helped me in the past, I was surprised to find that Microsoft are retiring the Microsoft TechNet Script Center. They have a link to an article on their Microsoft docs blog site explaining that they will no longer be maintaining this resource (date to be finalised)
It’s a massive shame but somewhat understandable. Ed Wilson - The Scripting Guy, who I followed for many years, retired some three years ago and the Scripting Guy Blog Site has since been maintained by a team of Premier Field Engineers, with many good articles and tips. This is still available and hopefully continues for some time to come. You can also follow them on @scriptingguys
When I read the blog post, it felt like the end of an era and certainly made me feel old. I also laughed as it made me think of the BOFH retiring and his PFY being promoted. “The PFY had a good teacher, who also taught me a thing or two”. The Script Center has been somewhere that I and no doubt many IT Admins relied on for VBScripts, Batch Files and also PowerShell, offering scripts for reporting, user administration and many other automated task. Like any good resource, these scripts and snippets have been hacked and altered and used to automate more and more and turn our often arduous tasks into something orchestrated and hassle free. As the tech industry has changed, many of the contributors and indeed myself have moved on and are using repositories like GitHub, GitLab, BitBucket etc to host their code, so whilst this resource will no longer be available, there are plenty of places to get your coding fix.
Microsoft’s documentation transition wasn’t something they did in a rush and docs.microsoft.com is something of a premiere resource when it comes to all things Microsoft.
PowerShell Gallery
Anybody looking for their next useful PowerShell script or indeed module has far more locations than there ever used to be. My favourite and certainly the easiest to access from PowerShell due to the package management features, is the PowerShell Gallery where there are a variety of modules, from Database Management to ChatOps and certainly far too many to list here.
dbatools
dbatools documentation
Modules and Package Management
The PowerShellGet module has a handful of commands that enable you to search for and install the many different modules.
Get-Command
Get-Command -Module PowerShellGet
CommandType Name Version Source
----------- ---- ------- ------
Function Find-Command 2.2.4.1 PowerShellGet
Function Find-DscResource 2.2.4.1 PowerShellGet
Function Find-Module 2.2.4.1 PowerShellGet
Function Find-RoleCapability 2.2.4.1 PowerShellGet
Function Find-Script 2.2.4.1 PowerShellGet
Function Get-CredsFromCredentialProvider 2.2.4.1 PowerShellGet
Function Get-InstalledModule 2.2.4.1 PowerShellGet
Function Get-InstalledScript 2.2.4.1 PowerShellGet
Function Get-PSRepository 2.2.4.1 PowerShellGet
Function Install-Module 2.2.4.1 PowerShellGet
Function Install-Script 2.2.4.1 PowerShellGet
Function New-ScriptFileInfo 2.2.4.1 PowerShellGet
Function Publish-Module 2.2.4.1 PowerShellGet
Function Publish-Script 2.2.4.1 PowerShellGet
Function Register-PSRepository 2.2.4.1 PowerShellGet
Function Save-Module 2.2.4.1 PowerShellGet
Function Save-Script 2.2.4.1 PowerShellGet
Function Set-PSRepository 2.2.4.1 PowerShellGet
Function Test-ScriptFileInfo 2.2.4.1 PowerShellGet
Function Uninstall-Module 2.2.4.1 PowerShellGet
Function Uninstall-Script 2.2.4.1 PowerShellGet
Function Unregister-PSRepository 2.2.4.1 PowerShellGet
Function Update-Module 2.2.4.1 PowerShellGet
Function Update-ModuleManifest 2.2.4.1 PowerShellGet
Function Update-Script 2.2.4.1 PowerShellGet
Function Update-ScriptFileInfo 2.2.4.1 PowerShellGet
Find-Module
Using the functions exposed by the PowerShellGet module, it is very simple to search the PowerShell Gallery for modules that will add functionality to your scripts and allow you to automate things like the creation and management of WiFi profiles.
PS C:\GitRepos> Find-Module -Name *wifi*
Version Name Repository Description
------- ---- ---------- -----------
1.7.5 WifiTools PSGallery A set of tools that can simplify handle Wi-Fi profiles, connection. Also additional tools …
0.5.0.0 wifiprofilemanagement PSGallery Leverages the native WiFi functions to manage WiFi profiles
1.0.0 WiFiProfileManagementDsc PSGallery PowerShell DSC resource for manage WiFi profile.
0.2.1 WiFi PSGallery Manage wireless profiles on the Windows operating system.
1.0 Get-WifiPassword PSGallery Returns list of known wifi networks with their passwords. The module uses netsh utility.
0.0.2 ProductivityTools.PSGetCurrentWifi… PSGallery It returns current wifi password
PS C:\GitRepos>
Install-Module
Once you have found what you are looking for, it can then be installed like so:-
Install-Module -Name WifiTools -Scope CurrentUser
Publish-Module
You may also have seen in PowerShellGet’s command list, you can also publish your modules to the Gallery. All of this can be performed from the command line, meaning you never really have to leave the shell.
Publish-Module -Name <moduleName> -NuGetApiKey ********-****-****-****-************
I am sure however that I will cover more about that another time. There are already however, plenty of other bloggers who have written about this subject already. This is a well written article that you should consider reading if you are in the market to publish your module to the gallery or if you are just interested in the process.
ramblingcookiemonster - Building a PowerShell Module
Where and Why
PowerShell has been around now for some time and there are plenty of resources for finding, installing, creating and publishing modules; many of which have been around for some time and plenty to show you how to create your own.
Where
Below I have listed some of the resources I have used in the past. Thankfully educating yourself these days is made much easier, as technology has moved on from my early days of studying and having to get a book from the library or the local bookstore (yes I am that old). It is now available to be consumed in various formats; Blog posts, YouTube videos, electronic books and I am sure if you want to, good old fashioned books are still available.
An Introduction to PowerShell Modules
Creating New PowerShell Projects
Don Jones Toolmaking
The PowerShell Scripting and Toolmaking Book
Learn Windows PowerShell in a Month of Lunches
Why
I have had numerous conversations in the past with IT Admins, advocating the need to learn PowerShell and great fun in helping my colleagues at work with any and all PowerShell questions. I am sure we have all had conversations in the past that have been similar in experience to this post - PowerShell Is Too Hard. Thankfully I have also had plenty where the outcome has been fruitful and I have been able to help some find the value in spending the time learning to use PowerShell to automate the monotonous or just lengthy tasks they need to perform on a regular basis. I have even managed to coerce one of my friends who is a Software Developer into creating his own modules. Hopefully in continuing to write articles, I can convince or help more people to learn the benefits of PowerShell and its many uses.
Future Articles
I know many people think they don’t have much to offer but having started blogging I look forward to offering if not a completely unique perspective, yet another place people can go to learn more about PowerShell.
I can tell you are all on the edge of your seats and looking forward to the next instalment. I hope to write about some of the following, preferably during the day
- Building a Jekyll Blog Dev Server.
- PowerShell Profiles (everyone should have one)
- My son’s recent lesson on 2FA and why its important
- Modules, CmdLets, Functions and Scripts…..
- and no doubt many other IT/PowerShell related posts
Having reached the end of this post with the 5th movie from the Fast and Furious box set playing in the background, I have a much greater appreciation for those who are already blogging and whose sites I have frequented in the past. I hope this also becomes just as useful to anyone who turns up for a read.