#
Get-SecurePassword Powershell Module
#
Super Buzzing 🤯
So I am proper buzzing, like I only started this particular blog site last month in July 2022 as I knew my current contract was coming to an end, and in a bit over a month this is the 15th Powershell module I have contributed, and I done some more blogs on-top of the recent modules, just to kind of verify I am a real human being, including information on past work I could think of which I had to solve which no-body previously could solve. I updated my resume and chucked that on this site, as I am currently looking for work, in hindsight I should have been applying for jobs more, but I have had an amazing few days at home with the family enjoying life with this amazingly hot weather we are still having. Best of all I am not stuck in an office melting through the current heatwave, but on the downside I'm not bringing in any cash sitting at home.
Anyways I am not buzzing due to unemployment, but the fact that this website is getting some attention, like I hit 3GB of traffic, but like the day before it was on 2GB I was like no way. Whilst I been building this website I been trying to promote it in various posts, as these modules may or may not be useful to you. I was kind of hoping it would lead to a new job.
Instead it has now lead to me getting an invite to actually speak about Powershell for a few different events that will then be available on youtube! Damn! Never did I expect that attention to be getting noticed by people inside and outside of the UK and then being invited to stuff that people who I massively respect have been on...It's almost like I been signed by the UFC, but don't worry folks I would never follow in Connor's footsteps and be a sell-out. I want to keep true to my roots, and I tried to do that in this blog. Just feels like that saying when one door closes another opens I know that sounds a bit like a fortune cookie, but just focusing on this massive positive in my life right now, and hoping it can lead to opening a few more doors in the right direction.
Honestly I am so stoked to be invited to speak on anything. I mean I am not an extrovert type of person, I just like to earn money, and spend time with the family. The days of going to raves till silly o'clock in the morning are long gone. I just type blogs till silly oclock instead now.
Sorry got a bit lost in the moment I didn't want to do any spoiler alerts so no event names mentioned
#
Super Secure Password Generator
Back to the agenda of this blog and the reason I gone and smashed another binary module together. It only seems like yesterday that I was typing a blog about a module I wrote...hang-on I was 😁 yep total Powershell Addict so I as I been looking for jobs as of late, I see a lot all mentioning Active Directory or Azure AD so I kind of figure I will be dealing with those two well know systems again. I am very comfortable using the ActiveDirectory module to carry out tasks, but having been in this industry for quite sometime, I always find companies rely on a particular website to generate the passwords for either new accounts, or people who have forgotten their password.
Thankfully I do not deal with those particular type of calls, but for the people that do, they then have to open a new tab or a browser session go to that website then generate the password, copy it or read it back to the customer. So if that is the set process everytime, I just got thinking randomly tonight how much time is then spent by the human performing that task? It might be a minute? It might be under a minute. But what if that particular support person gets 50 of those types of calls a day? Then how much time in the day is spent following that manual process?
Automation to the rescue, and a new module to let my possible future employer know about. So although I saw a few password generators on the Powershell gallery, I did not see the mention of OWASP nor did I see the mention of binary. For me that was enough to put on the kettle, and make a nice brew of Yorkshire Tea and find a C Sharp library to do the hard work for me.
#
Package I Used 📦
So this package seemed to tick all the boxes for what I was looking for. So it was time to get to work and build this module and include each parameter for this module. I like building modules that have examples. It was the same when I was building Universal Dashboard modules, it made the job a lot easier understanding the project in another languge if it has an example. This particular package showed several examples that all seemed really easy to understand and follow along. I do struggle a little when doing these binary modules as it is all in C Sharp and I have never ever done any studying or lessons in that language, and unlike Powershell it, is not quite as easy to follow along. Like I know when using a function you can do a Validate list etc, but again as it is a CS file this is being built from I wanted to keep it simple. From looking at the example I figured I could pass all the parameters apart from the password length as oldskool boolean parameters again I know if this was pure Powershell I would have opted for a switch but I don't know how to make the C Sharp behave in that way. Hence I opted for the parameters to all be boolean apart from the password length which is an integer value between 8 and 128 characters long
In my little brain I am now thinking the support agent could now have a tool that they just have to run once, maybe they could make it into a their own function to then just press a play button in the ISE console, saving them from having to browse to the site and then generate the password. Even though this would save a small amount of time, but you add that up over the day, then over a week, then month, then year....you get what I am saying...?
#
Making Sure I Added Decent Help 📝
Due to the UK 🇬🇧 still being incredibly hot at the moment, and the fact we don't have fancy air-conditioning it has meant me getting to sleep has taken a bit longer than usual. So instead of just laying there thinking I'm hot, I'm hot, I'm really hot. I been spending my evenings making some new module, then writing a blog on it. I do feel very creative late at night, so try to use that creativity to do something positive, I can over-look certain things. Like adding a proper help to the module. So this time round I made sure I added a decent help message for each parameter to be used. I also found when testing if I missed a boolean parameter, the module threw a wobbly. So I had to make all parameters mandatory to make sure the underlying .Net OWASP standard password generator would run without issues.
NAME
Get-SecurePassword
SYNTAX
Get-SecurePassword -PasswordLength <int> -IncludeLowerCase <bool> -IncludeUpperCase <bool> -IncludeNumeric <bool> -IncludeSpecial <bool> [<CommonParameters>]
PARAMETERS
-IncludeLowerCase <bool>
Enter either $true to include lower-case characters in the generated password. Or $false if you do not want lower-case characters included in the password
Required? true
Position? Named
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
Accept wildcard characters? false
-IncludeNumeric <bool>
Enter either $true to include numeric numbers in the generated password. Or $false if you do not want numeric numbers included in the password
Required? true
Position? Named
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
Accept wildcard characters? false
-IncludeSpecial <bool>
Enter either $true to include special characters in the generated password. Or $false if you do not want special characters included in the password
Required? true
Position? Named
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
Accept wildcard characters? false
-IncludeUpperCase <bool>
Enter either $true to include upper-case characters in the generated password. Or $false if you do not want upper-case characters included in the password
Required? true
Position? Named
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
Accept wildcard characters? false
-PasswordLength <int>
Must be an int for to set the password length between 8 and 128 is the allowed range
Required? true
Position? Named
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
#
Examples 🔈
Please see these examples below, I also included the output of the command so you can see the type of random secure passwords this generates:-
Get-SecurePassword -PasswordLength 23 -IncludeLowerCase $false -IncludeUpperCase $true -IncludeNumeric $false -IncludeSpecial $true
KVEFF*OVOV\KDHWHAR!SNAT
Get-SecurePassword -PasswordLength 12 -IncludeLowerCase $true -IncludeUpperCase $true -IncludeNumeric $true -IncludeSpecial $true
S9#R$\ZXSJjx
Get-SecurePassword -PasswordLength 72 -IncludeLowerCase $true -IncludeUpperCase $true -IncludeNumeric $true -IncludeSpecial $false
WQu2BObZ1AJZP8MrOvcYvOOc41xZAarBmCcOWhGJGhy6gFm13Ubm2rzGoaRJCO6a0McTasRC
#
Find-Gif Was Useful 😑
I been recently saying to recruitment agencies about how I am passionate about scripting and being able to write advanced modules to be used for more than just one thing. As it turns out Find-Gif helped me locate the icon I used to publish this module with on the Powershell gallery. So it was super cool to be able to not only use that module for my own personal website, but to also use it to find a cool icon for this module. See you really can use stuff for more than just one thing. Okay Find-Gif might not be the prime example, but it saved me wasting time on the internet looking, when I did it all from the shell.
To put it right before your eyes 👀 a simple explanation on the right-hand-side telling you the new parameter name for the old parameter name like I am sure /S
is for the system name of the computer, but -ComputerName
for me is a lot more easier, and it goes with the common parameter list for this which other Powershell cmdlets use which again just makes this less like a foreign language to me and a lot more easier to understand.
#
Update 💬
Okay I always take on board what people have to sa about my work, or the work I produce. So I had someone saying they thought I should have used the NEW verb instead of the GET verb. I explained my reason behind using get, instead of new, because I wanted to get a secure password. However I decided to bring in the one of the top dogs on this debate, and well it back-fired in doing so, as indeed I should have used the new verb, as a new password is being generated each time. So I decided I would update the module to also include the new verb, and also keep the get verb (as I didn't fancy renaming this whole blog as well) so these both do the exact same thing, just two ways of using the same cmdlet. I know I could of made this an alias but I just thought I would do another namespace for it.
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-SecurePassword 1.0.2 get-securepassword
Cmdlet New-SecurePassword 1.0.2 get-securepassword
#
That Really Is All 👋
I know this is not something brand-new for Powershell, and I know there were a few things on the Powershell gallery already which did this. However as mentioned I didn't see the word OWASP being mentioned, nor did I see the word Binary being mentioned. This was a super cool small project to work on in the evening, as I have also mentioned the fact people are doing this manually, I mean could even package this into an EXE to just let a junior support member double click to get a password each time. It would still save time from having to go to a website, wait for the site to load, point and clicking the generate button, and then getting the password. Well till the next idea I come up with take care and stay safe.