My little part of the Internet

Category: Engineering

Generating Passwords using PowerShell

Even now – after all this time – passwords are hard.

Yes, I know we should all be using Cloud with its fancy KeyStore/Key Vaults or enterprise store such as CyberArk. We all know we should not be chosing them. However, like it or not ‘things’ still need passwords. Whether its for an encryption key, wireless network or just a plain and simple password.

Vendors are also part of the problem, placing restrictions on types of characters or even positioning of them within a password. Still. In 2020! (VMware and Cisco are pretty horrific at this)

Also when you are building stuff in automation, its inevitable you will need some sort of password generating. I use PowerShell a lot and found methods that could be used to do this.

Voila my new GitHub project https://github.com/kevsterd/PoSH-Passwords

This is based on using the Psuedo Random Number Generator (PRNG) which is a feature provided by the Windows Cryptographic Service Provider (CSP) which generates randomness in a ‘good enough’ manner. If you need more than this then well you know why and what to do about it but for most uses this is pretty good.

It uses vendor safe methods and arrangments out of the box with a pretty good 16 character length. You can append flags to make it stronger, output a number of them or make them readable. Its up to you. Your choice.

# Import the module
PS > import-module .\Password-Functions.psm1

# Run the function
PS > New-Password
LC*ATg2F0CFmh-r4

Want longer length ? Want more than one ?

PS > New-Password -Length 20 -count 3
uVelF$qejS4B.J$I8hmO
I9h+Wx1fJeUw8OxWf@DA
QbvykhouQ@tHe1IuQDPE

Remember, the passwords being returned back as an object you can then store into other variables.

PS > $pass=New-Password

You can obviously use the PowerShell SecureString method to store and manipulate if need be. (Some decent tips at http://blog.majcica.com/2015/11/17/powershell-tips-and-tricks-decoding-securestring/)

PS > $pass=New-Password

PS > $secpass=(ConvertTo-SecureString $pass -AsPlainText -Force)
PS > $secpass
System.Security.SecureString

PS > $secpass | ConvertFrom-SecureString
01000000d08c9ddf0115d1118c7a00c04fc297eb010000002571feb3508bb14b8eaa7cac1828a6b80000000002000000000010660000000100002000000064fc1cf1a0b044b4a1dd63aa3fc9ba9ec4f83b24a70569cbbe25773522868bd4000000000e80000000020000200000004487a5581bbc0d7ffcb47bdfda87198014a8cce89b9ed117b1c29893e9d3481b3000000058b14398fa542e694ce5b9a37299b147f5c9640e33f4c6603b7a2131c79c23d22301870794d266ea52b5194ebdb1326a40000000db1dec8a79db34f89846c015fb6a37f4116cb15c48ccd9dcecbd8dfc16a3a1209207be1a9e53e1b37870cdf04c693ff9a41f100d5197d42d7326e4680c6941b9

PS > $secpass | ConvertFrom-SecureString | Out-File ".\MyPassword.txt"

HP Microserver N40 Disk Upgrades ….. more than 4 disks ?

I use a HP Microserver N40 for use at our office.   Its a great peice of kit that I have had for a number of years and is used for a variety of purposes such as NAS, Media Sharing, Print/File Server and Virtual Machine host…
I recently decided to upgrade from Windows Home Server 2011 to Windows Server Essentials 2012 R2, as well as some hardware upgrades.

Sadly i found that Essentials 2012 R2 does not have a driver availible so support for this RAID card is not possible.  One thought was to use the Server 2008 R2 X64 driver but sounds a bad idea to me.   I then decided to look at using Windows Server Storage Spaces which is a technology Microsoft have been working on for a long time.  I had 2 x 4TB WD Green and 2 x 2TB WD Green drives in the 4 way SATA bay.
Not wanting to install the OS on the 4TB drives, I decided to make use of a spare SSD.  This was then connected to the motherboard SATA port.
I then realised there is an E-SATA port on the rear of the server.   With a bit of a Heath Robinson hack I managed to get this routed internally and then into a spare hot swap 3.5″ bay I had spare that I installed into the CD Drive 5 1/4″ bay.  The mod was to bend the left edge of the flap that covers the PCI slot screws outwards with a multitool which allows the E-SATA cable to be routed internally.

A quick addition of a SATA power splitter and job done.   Six drives in a four drive server !
I need to make sure recovery will work storage spaced going forward but the Heath Tools in Server Essentials seem to to quite good so time will tell.
Looking good so far….

CISSP

Finally had notification that I now am offically CISSP certified !

I’m not a certification chaser but decided late last year I wanted to do something different to pure technical qualifiactions.  It was a very long (6 hour/250 questions – some interative) exam and certification process but now all done.  Very happy.
Next is keeping up with various things to gain CPE’s
I think Certified Ethical Hacker (CEH) next……

Putty – Session Logs

A useful feature when you are working on multiple devices is to keep as session log for every session.  You can then easilly see what you have typed or provide evidence.
To configure this for every session:
1) Open Putty
2) Select the Default Settings and press Load

3) Navigate to Session > Logging
4) Set the Log file name in a format that makes sence to you.  You can see mine

5) Navigate back to the sessions, making sure Default Settings is still highlighted and then press Save
Test !

© 2024 Kevsters Blog

Theme by Anders NorénUp ↑