Thank you for your interest in Redapt. Whether you are a current customer or are interested in becoming one, we are here to help. Just input a few bits of information, and we'll quickly connect you with a helpful Redapt expert.
If you are like me, you connect to Azure via PowerShell sometimes dozens of times a day or more. I’m sure everyone has their shortcuts to make things like this quicker, and involve less typing, mine was to write some PowerShell.
At a basic level, the code adds some functions that allow you to save credentials in the Current User’s registry hive in an encrypted manner, and recall them to automatically connect, or validate an existing connection, to an Azure RM Subscription.
The module is published on Microsoft’s PowerShell Gallery, making installation super easy.
I initially created just a PowerShell Library that could be dot sourced into a PowerShell session which I added to my PowerShell profile so it automatically loaded when I opened a PowerShell session.
For fun, I have now created a PowerShell module that can be installed from the PowerShell gallery, or downloaded from GitHub and dropped into your modules folder to provide the same functionality as the library.
Both the library and module can be downloaded from GitHub if you would like to experiment with them. All relevant links at the end of the post. Obligatory legal verbiage, all risk of use, and the results of use are with the user. This code is provided as is, with no warranty of any kind.
The meat and potatoes of the code creates a new Key in your HKCU registry hive at [System\CurrentControlSet\] called [SecCreds] the first time you use the New-SavedCreds function. New Keys are also created for each Credential that you save.
Hint: Don’t make your names complicated, that’s what you use to recall them!
The UserName is stored in clear text and the Password is stored as a SecureString value which utilizes the built in Windows Data Protection (WDP) to encrypt the password in a way that only the user who created it, can decrypt it**. If you’d like to read more on WDP, the link is at the end of the post.
Disclaimer: WDP is a password based protection system – if your password to the local machine gets compromised, any credentials encrypted in the registry should also be considered burnt.
Both the library and the module have a full built-in help.
PS C:\Scripts> . .\AzureConnectionHelperLibrary.ps1
Loading the library without the [-Silent] option will display full help for the Library as a whole and syntaxes for each function.
PS C:\> help about_AzureConnectionAssistant
This will display comprehensive help information, including the function syntax and examples on each functions usage.
Additional information can be found in the README.md file in the GitHub repository.
· Download AzureConnectionAssistant from PowerShell gallery
· Download AzureConnectionAssistant from GitHub
· View AzureConnectionAssistant Readme
· Read more on Windows Data Protection WDP
· View PowerShell Gallery Readme