Powershell Password Tool

In the dark days before Windows Authentication was so embedded in (non-microsoft) mainstream applications, Windows users had to remember a myriad of passwords for a plethora of applications. Application development has changed - but relics from previous software eras remain. On desktops all over the world lay applications that were not developed to plug into any external authorization system. Passwords must still be remembered.

At work, I have access to a decent number of passwords that, due to the intermittent nature of their use or their necessary complexity, I just cannot remember. The ideal way to store these would be in a secure repository to which only I have access. An issue remains - sometimes it is necessary to input a password when another user is present - a user with lesser privileges in the given system. The tendency is to ask the user to turn around while I sneak the password from the repository and paste it into the login form…an effective solution but not very elegant.

So I came up with a little powershell script, which allows me to select a password category (e.g. the admin password for a source control system), pulls the password from the SQL repository and outputs it to the clipboard. It took no more than 30 minutes of programming, and I have been using it effectively ever since.

Here's the breakdown:

  1. I created a simple SQL2005 repository, with one table containing the menus (for instance SQL Admin passwords, Source Control Admin Passwords etc.) and another containing a server name and the password for that server. I did not use any encryption in this example, but you can see how easy it would be to do so. Here's a simple DB diagram:










  2. I downloaded and installed PowerSMO (http://www.pluralsight.com/dan/samples/ST-PowerSMO.zip), allowing my powershell script to talk to the SQL database that I just created.
  3. I created the below script to pull the password in question from the database and piped it to the clip command - an inbuilt vista executable which allows the programmatic passing of objects to the windows clipboard.


    Note: the clip executable is located in the System32 directory in Windows Server 2003/Windows Vista. While I cannot attest to the legality of (and therefore cannot recommend) copying clip.exe from your copy of Vista into the same folder on your Windows XP box, the clip.exe functionality can be mimicked on an XP box by doing so. Technically speaking, this script should work on an XP box also.










  4. Actually, there is no 4. Now when I'm in an awkward situation, I crack open powershell and pass my password to the clipboard! It's as simple as that. Please feel free to test this script out and let me know how it works!

Comments

Popular posts from this blog

Excel - Adding an existing Pivot table to the data model

Mirth

Getting Started with Mirth (Part 1)