If you’re just looking for a one-liner, the following code will take a username and password, store them into a PSCredential object, and then export the results into an XML file. Note: If you do want to secure share credentials between computers, check out Kris Powell’s post entitled Secure Password with PowerShell: Encrypting Credentials. I’m almost positive that security professionals are growing grey hairs from my shenanigans, but I’m not overly concerned about credentials to access my test framework. I also don’t want anyone else using my secure string and thus avoided using Key/SecureKey. I tinkered around with keeping the PSCredential in memory and addressing it with a Global scope, but that seemed overkill for what I’m trying to do. Exporting the PSCredential object into an XML file to make the credentials locally persistent.Creating a PSCredential object with the username and password of an ad-hoc lab account.This was something I needed to address because I wanted to automate the initiation of the tests themselves while keeping a secure set of encrypted credentials that are only valid for the workstation I’m using. Ren and Stimpy pioneered unit testing and yak shavingīefore I go too deep down that rabbit hole, however, I thought I’d share how I’m generating private test credentials for automated local testing. The idea is to create unit tests and/or integration tests for your code and use it to validate that changes being introduced (either to your code or the upstream target) is still valid for the use case and project. In an earlier post, I introduced you to Pester, a unit testing framework for PowerShell.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |