{"id":348,"date":"2020-02-08T14:56:18","date_gmt":"2020-02-08T14:56:18","guid":{"rendered":"https:\/\/iddles.co.uk\/?p=348"},"modified":"2020-02-08T14:59:20","modified_gmt":"2020-02-08T14:59:20","slug":"generating-passwords-using-powershell","status":"publish","type":"post","link":"https:\/\/iddles.co.uk\/index.php\/2020\/02\/08\/generating-passwords-using-powershell\/","title":{"rendered":"Generating Passwords using PowerShell"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Even now &#8211; after all this time &#8211; passwords are hard.   <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 &#8216;things&#8217; still need passwords.  Whether its for an encryption key, wireless network or just a plain and simple password.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.   <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Voila my new GitHub project <a href=\"https:\/\/github.com\/kevsterd\/PoSH-Passwords\">https:\/\/github.com\/kevsterd\/PoSH-Passwords<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 &#8216;good enough&#8217; 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Import the module\nPS > import-module .\\Password-Functions.psm1\n\n# Run the function\nPS > New-Password\nLC*ATg2F0CFmh-r4<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Want longer length ? Want more than one ?<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS > New-Password -Length 20 -count 3\nuVelF$qejS4B.J$I8hmO\nI9h+Wx1fJeUw8OxWf@DA\nQbvykhouQ@tHe1IuQDPE<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remember, the passwords being returned back as an object you can then store into other variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS > $pass=New-Password<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can obviously use the PowerShell SecureString method to store and manipulate if need be. (Some decent tips at <a href=\"http:\/\/blog.majcica.com\/2015\/11\/17\/powershell-tips-and-tricks-decoding-securestring\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"http:\/\/blog.majcica.com\/2015\/11\/17\/powershell-tips-and-tricks-decoding-securestring\/ (opens in a new tab)\">http:\/\/blog.majcica.com\/2015\/11\/17\/powershell-tips-and-tricks-decoding-securestring\/<\/a>)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS > $pass=New-Password\n\nPS > $secpass=(ConvertTo-SecureString $pass -AsPlainText -Force)\nPS > $secpass\nSystem.Security.SecureString\n\nPS > $secpass | ConvertFrom-SecureString\n01000000d08c9ddf0115d1118c7a00c04fc297eb010000002571feb3508bb14b8eaa7cac1828a6b80000000002000000000010660000000100002000000064fc1cf1a0b044b4a1dd63aa3fc9ba9ec4f83b24a70569cbbe25773522868bd4000000000e80000000020000200000004487a5581bbc0d7ffcb47bdfda87198014a8cce89b9ed117b1c29893e9d3481b3000000058b14398fa542e694ce5b9a37299b147f5c9640e33f4c6603b7a2131c79c23d22301870794d266ea52b5194ebdb1326a40000000db1dec8a79db34f89846c015fb6a37f4116cb15c48ccd9dcecbd8dfc16a3a1209207be1a9e53e1b37870cdf04c693ff9a41f100d5197d42d7326e4680c6941b9\n\nPS > $secpass | ConvertFrom-SecureString | Out-File \".\\MyPassword.txt\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Even now &#8211; after all this time &#8211; 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 &#8216;things&#8217; still need passwords. Whether its for an encryption key, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[3,82,81,11],"tags":[86,78],"class_list":["post-348","post","type-post","status-publish","format-standard","hentry","category-engineering","category-powershell","category-scripting","category-security","tag-passwords","tag-powershell","post-preview"],"_links":{"self":[{"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=348"}],"version-history":[{"count":4,"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/348\/revisions"}],"predecessor-version":[{"id":352,"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/348\/revisions\/352"}],"wp:attachment":[{"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iddles.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}