Stop typing PowerShell credentials in demos using PowerShell SecretManagement

Published Apr 14 2021 04:02 AM 28.3K Views
Microsoft

We all sometimes create presentations with some PowerShell demos. And often, we need to use credentials to log in to systems for example PowerShell when delivering these presentations. This can lead that we don't use very strong passwords because we don't want to type them during a presentation, you see the problem? So, here is how you can use the PowerShell SecretManagement and SecretStore modules to store your demo credentials on your machine.

 

Doing this is pretty simple:

 

Install the SecretManagement and SecretStore PowerShell modules.

 

Install-Module Microsoft.PowerShell.SecretManagement, Microsoft.PowerShell.SecretStore

 

Register a SecretStore to store your passwords and credentials. I this example we are using a local store to do that. Later in this blog post, we will also have a look at how you can use Azure Key Vault to store your secrets. This is handy if you are working on multiple machines.

 

Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault

 

Now we can store our credentials in the SecretStore. In this example, I am going to store the password using, and I will add some non-sensitive data as metadata to provide some additional description.

 

Set-Secret -name DemoAdmin01 -Secret "demoAdmin01PassWord" -Metadata @{demo = "My Hyper-V demo for Windows Server and Linux Remoting"}

 

You can also store other data types like PSCredential in SecretManagement. For this example, I am using just a simple string, because this works for most scenarios. 

 

PowerShell SecretManagement supports the following secret data types:

  • byte[]
  • string
  • SecureString
  • PSCredential
  • Hashtable

 

Store Secret in PowerShell SecretStoreStore Secret in PowerShell SecretStore

Now you can start using this secret in the way you need it. In my case, it is the password of one of my admin users. 

 

$DemoAmdin01secret = Get-Secret -Vault SecretStore -Name DemoAdmin01
$DemoAmdin01Cred = New-Object -TypeName PSCredential -ArgumentList "DemoAdmin01", $DemoAmdin01secret

 

As mentioned before, you can also store a PSCredential object directly in SecretManagement if that makes it easier for you.

These two lines, I could also store in my PowerShell profile I use for demos, or in my demo startup script. In this case, the credential object is available for you to use.

 

Use SecretStore credentialsUse SecretStore credentials

 

If you are using multiple machines and you want to keep your passwords in sync, the Azure Key Vault extension.

 

Install-Module Az.KeyVault
Register-SecretVault -Module Az.KeyVault -Name AzKV -VaultParameters @{ AZKVaultName = $vaultName; SubscriptionId = $subID}

 

Now you can store and get secrets from the Azure Key Vault and you can simply use the -Vault AzKV parameter instead of -Vault SecretStore. 

I hope this blog provides you with a short overview of how you can leverage PowerShell SecretManagement and SecretStore, to store your passwords securely. If you want to learn more about SecretManagement check out Microsoft Docs.

 

Want to learn how to install PowerShell 7? Check out my video on Microsoft Channel 9.

 

 

I also highly recommend that you read @Pierre Roman blog post on leveraging PowerShell SecretManagement to generalize a demo environment.

7 Comments
Senior Member

This is really cool use case for it :) Thanks for sharing!!!

 

Happy Azure Stacking!!!

Occasional Contributor

Nice, qurestion this local vault is register on user account or all Admins of machnie can access to vault or is there some ACL who can access ?

Occasional Visitor

Can this be used with scripting to avoid situations where username/password has to be stored in a restricted text file (i.e. when it's not possible to use a service account)?

New Contributor

Also have a similar question as @ChuckFinley 

 

From a quick review of this, if I am going to use this in automation I still need to to keep the Vault password somewhere, i.e in a XML document. What has been missed from this document is that if you open up a fresh PowerShell window, when you run the first Get/Set-Secret it asks for a password.

@thomasmaurer - Thoughts around using this when you have a "scheduled task" machine running your scripts?

Microsoft

@ChuckFinley Yes, absolutely! 

 

@NMLVS Yes, so there is an example in the announcement blog, let me quote that part here:

 


Using the SecretStore in Automation

This is an example of automation script that installs and configures the Microsoft.PowerShell.SecretStore module without user prompting. The configuration requires a password and sets user interaction to None, so that SecretStore will never prompt the user. The configuration also requires a password, and the password is passed in as a SecureString object. The -Confirm:false parameter is used so that PowerShell will not prompt for confirmation.

The SecretStore password must be provided in a secure fashion. Here the password is being imported from an encrypted file using Windows Data Protection API, but this is a Windows only solution. Another option is to use a CI system mechanism such as secure variables.

Next, the SecretManagement module is installed and the SecretStore module registered so that the SecretStore secrets can be managed.

The Unlock-SecretStore cmdlet is used to unlock the SecretStore for this session. The password timeout was configured for 1 hour and SecretStore will remain unlocked in the session for that amount of time, after which it will need to be unlocked again before secrets can be accessed.

 

Install-Module -Name Microsoft.PowerShell.SecretStore -Repository PSGallery -Force
$password = Import-CliXml -Path $securePasswordPath

Set-SecretStoreConfiguration -Scope CurrentUser -Authentication Password -PasswordTimeout 3600 -Interaction None -Password $password -Confirm:$false

Install-Module -Name Microsoft.PowerShell.SecretManagement -Repository PSGallery -Force
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault

Unlock-SecretStore -Password $password

 

Microsoft

@Michal Machniak There is also a SecretStore Scope setting, but it is currently set to CurrentUser and cannot be changed.

If you need to sync passwords between multiple users, you could register the Azure Key Vault for every user as an SecretStore

Occasional Visitor

Hey @thomasmaurer,

 

Thanks for sharing great content. Can you share what color theme you are using for your terminal?

%3CLINGO-SUB%20id%3D%22lingo-sub-2272166%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2272166%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20really%20cool%20use%20case%20for%20it%20%3A)%3C%2Fimg%3E%20Thanks%20for%20sharing!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHappy%20Azure%20Stacking!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2272374%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2272374%22%20slang%3D%22en-US%22%3E%3CP%3ENice%2C%20qurestion%20this%20local%20vault%20is%20register%20on%20user%20account%20or%20all%20Admins%20of%20machnie%20can%20access%20to%20vault%20or%20is%20there%20some%20ACL%20who%20can%20access%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2272412%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2272412%22%20slang%3D%22en-US%22%3E%3CP%3ECan%20this%20be%20used%20with%20scripting%20to%20avoid%20situations%20where%20username%2Fpassword%20has%20to%20be%20stored%20in%20a%20restricted%20text%20file%20(i.e.%20when%20it's%20not%20possible%20to%20use%20a%20service%20account)%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2272792%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2272792%22%20slang%3D%22en-US%22%3E%3CP%3EAlso%20have%20a%20similar%20question%20as%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1025975%22%20target%3D%22_blank%22%3E%40ChuckFinley%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFrom%20a%20quick%20review%20of%20this%2C%20if%20I%20am%20going%20to%20use%20this%20in%20automation%20I%20still%20need%20to%20to%20keep%20the%20Vault%20password%20somewhere%2C%20i.e%20in%20a%20XML%20document.%20What%20has%20been%20missed%20from%20this%20document%20is%20that%20if%20you%20open%20up%20a%20fresh%20PowerShell%20window%2C%20when%20you%20run%20the%20first%20Get%2FSet-Secret%20it%20asks%20for%20a%20password.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F278133%22%20target%3D%22_blank%22%3E%40thomasmaurer%3C%2FA%3E%26nbsp%3B-%20Thoughts%20around%20using%20this%20when%20you%20have%20a%20%22scheduled%20task%22%20machine%20running%20your%20scripts%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2273301%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2273301%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1025975%22%20target%3D%22_blank%22%3E%40ChuckFinley%3C%2FA%3E%26nbsp%3BYes%2C%20absolutely!%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F960255%22%20target%3D%22_blank%22%3E%40NMLVS%3C%2FA%3E%26nbsp%3BYes%2C%20so%20there%20is%20an%20example%20in%20the%20announcement%20blog%2C%20let%20me%20quote%20that%20part%20here%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%0A%3CH3%20id%3D%22toc-hId-2004207737%22%20id%3D%22toc-hId-2004207737%22%20id%3D%22toc-hId-2004207737%22%20id%3D%22toc-hId-2004207737%22%20id%3D%22toc-hId-2004207737%22%20id%3D%22toc-hId-2004207737%22%3EUsing%20the%20SecretStore%20in%20Automation%3C%2FH3%3E%0A%3CP%3EThis%20is%20an%20example%20of%20automation%20script%20that%20installs%20and%20configures%20the%20Microsoft.PowerShell.SecretStore%20module%20without%20user%20prompting.%20The%20configuration%20requires%20a%20password%20and%20sets%20user%20interaction%20to%26nbsp%3B%3CCODE%20class%3D%22%20prettyprinted%22%3E%3CSPAN%20class%3D%22kwd%22%3ENone%3C%2FSPAN%3E%3C%2FCODE%3E%2C%20so%20that%20SecretStore%20will%20never%20prompt%20the%20user.%20The%20configuration%20also%20requires%20a%20password%2C%20and%20the%20password%20is%20passed%20in%20as%20a%20SecureString%20object.%20The%26nbsp%3B%3CCODE%20class%3D%22%20prettyprinted%22%3E%3CSPAN%20class%3D%22pun%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EConfirm%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3A%3C%2FSPAN%3E%3CSPAN%20class%3D%22kwd%22%3Efalse%3C%2FSPAN%3E%3C%2FCODE%3E%26nbsp%3Bparameter%20is%20used%20so%20that%20PowerShell%20will%20not%20prompt%20for%20confirmation.%3C%2FP%3E%0A%3CP%3EThe%20SecretStore%20password%20must%20be%20provided%20in%20a%20secure%20fashion.%20Here%20the%20password%20is%20being%20imported%20from%20an%20encrypted%20file%20using%20Windows%20Data%20Protection%20API%2C%20but%20this%20is%20a%20Windows%20only%20solution.%20Another%20option%20is%20to%20use%20a%20CI%20system%20mechanism%20such%20as%20secure%20variables.%3C%2FP%3E%0A%3CP%3ENext%2C%20the%20SecretManagement%20module%20is%20installed%20and%20the%20SecretStore%20module%20registered%20so%20that%20the%20SecretStore%20secrets%20can%20be%20managed.%3C%2FP%3E%0A%3CP%3EThe%26nbsp%3B%3CCODE%20class%3D%22%20prettyprinted%22%3E%3CSPAN%20class%3D%22typ%22%3EUnlock%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E-%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ESecretStore%3C%2FSPAN%3E%3C%2FCODE%3E%26nbsp%3Bcmdlet%20is%20used%20to%20unlock%20the%20SecretStore%20for%20this%20session.%20The%20password%20timeout%20was%20configured%20for%201%20hour%20and%20SecretStore%20will%20remain%20unlocked%20in%20the%20session%20for%20that%20amount%20of%20time%2C%20after%20which%20it%20will%20need%20to%20be%20unlocked%20again%20before%20secrets%20can%20be%20accessed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EInstall-Module%20-Name%20Microsoft.PowerShell.SecretStore%20-Repository%20PSGallery%20-Force%0A%24password%20%3D%20Import-CliXml%20-Path%20%24securePasswordPath%0A%0ASet-SecretStoreConfiguration%20-Scope%20CurrentUser%20-Authentication%20Password%20-PasswordTimeout%203600%20-Interaction%20None%20-Password%20%24password%20-Confirm%3A%24false%0A%0AInstall-Module%20-Name%20Microsoft.PowerShell.SecretManagement%20-Repository%20PSGallery%20-Force%0ARegister-SecretVault%20-Name%20SecretStore%20-ModuleName%20Microsoft.PowerShell.SecretStore%20-DefaultVault%0A%0AUnlock-SecretStore%20-Password%20%24password%3C%2FCODE%3E%3C%2FPRE%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2273308%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2273308%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F11827%22%20target%3D%22_blank%22%3E%40Michal%20Machniak%3C%2FA%3E%26nbsp%3B%3CSPAN%3EThere%20is%20also%20a%20SecretStore%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EScope%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3Bsetting%2C%20but%20it%20is%20currently%20set%20to%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3ECurrentUser%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3Band%20cannot%20be%20changed.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIf%20you%20need%20to%20sync%20passwords%20between%20multiple%20users%2C%20you%20could%20register%20the%20Azure%20Key%20Vault%20for%20every%20user%20as%20an%20SecretStore%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2275668%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2275668%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F278133%22%20target%3D%22_blank%22%3E%40thomasmaurer%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20sharing%20great%20content.%20Can%20you%20share%20what%20color%20theme%20you%20are%20using%20for%20your%20terminal%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2272072%22%20slang%3D%22en-US%22%3EStop%20typing%20PowerShell%20credentials%20in%20demos%20using%20PowerShell%20SecretManagement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2272072%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20all%20sometimes%20create%20presentations%20with%20some%20PowerShell%20demos.%20And%20often%2C%20we%20need%20to%20use%20credentials%20to%20log%20in%20to%20systems%20for%20example%20PowerShell%20when%20delivering%20these%20presentations.%20This%20can%20lead%20that%20we%20don't%20use%20very%20strong%20passwords%20because%20we%20don't%20want%20to%20type%20them%20during%20a%20presentation%2C%20you%20see%20the%20problem%3F%20So%2C%20here%20is%20how%20you%20can%20use%20the%20PowerShell%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdevblogs.microsoft.com%2Fpowershell%2Fsecretmanagement-and-secretstore-are-generally-available%2F%3FWT.mc_id%3Dmodinfra-16864-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESecretManagement%20and%20SecretStore%20modules%3C%2FA%3E%26nbsp%3Bto%20store%20your%20demo%20credentials%20on%20your%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDoing%20this%20is%20pretty%20simple%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInstall%20the%20SecretManagement%20and%20SecretStore%20PowerShell%20modules.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EInstall-Module%20Microsoft.PowerShell.SecretManagement%2C%20Microsoft.PowerShell.SecretStore%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegister%20a%20SecretStore%20to%20store%20your%20passwords%20and%20credentials.%20I%20this%20example%20we%20are%20using%20a%20local%20store%20to%20do%20that.%20Later%20in%20this%20blog%20post%2C%20we%20will%20also%20have%20a%20look%20at%20how%20you%20can%20use%20Azure%20Key%20Vault%20to%20store%20your%20secrets.%20This%20is%20handy%20if%20you%20are%20working%20on%20multiple%20machines.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ERegister-SecretVault%20-Name%20SecretStore%20-ModuleName%20Microsoft.PowerShell.SecretStore%20-DefaultVault%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20we%20can%20store%20our%20credentials%20in%20the%20SecretStore.%20In%20this%20example%2C%20I%20am%20going%20to%20store%20the%20password%20using%2C%20and%20I%20will%20add%20some%20non-sensitive%20data%20as%20metadata%20to%20provide%20some%20additional%20description.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ESet-Secret%20-name%20DemoAdmin01%20-Secret%20%22demoAdmin01PassWord%22%20-Metadata%20%40%7Bdemo%20%3D%20%22My%20Hyper-V%20demo%20for%20Windows%20Server%20and%20Linux%20Remoting%22%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20store%20other%20data%20types%20like%20PSCredential%20in%20SecretManagement.%20For%20this%20example%2C%20I%20am%20using%20just%20a%20simple%20string%2C%20because%20this%20works%20for%20most%20scenarios.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPowerShell%20SecretManagement%20supports%20the%20following%20secret%20data%20types%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Ebyte%5B%5D%3C%2FLI%3E%0A%3CLI%3Estring%3C%2FLI%3E%0A%3CLI%3ESecureString%3C%2FLI%3E%0A%3CLI%3EPSCredential%3C%2FLI%3E%0A%3CLI%3EHashtable%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Store%20Secret%20in%20PowerShell%20SecretStore.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F272752iAFB714A3E32A7DDD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Store%20Secret%20in%20PowerShell%20SecretStore.jpg%22%20alt%3D%22Store%20Secret%20in%20PowerShell%20SecretStore%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EStore%20Secret%20in%20PowerShell%20SecretStore%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENow%20you%20can%20start%20using%20this%20secret%20in%20the%20way%20you%20need%20it.%20In%20my%20case%2C%20it%20is%20the%20password%20of%20one%20of%20my%20admin%20users.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24DemoAmdin01secret%20%3D%20Get-Secret%20-Vault%20SecretStore%20-Name%20DemoAdmin01%0A%24DemoAmdin01Cred%20%3D%20New-Object%20-TypeName%20PSCredential%20-ArgumentList%20%22DemoAdmin01%22%2C%20%24DemoAmdin01secret%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20mentioned%20before%2C%20you%20can%20also%20store%20a%20PSCredential%20object%20directly%20in%20SecretManagement%20if%20that%20makes%20it%20easier%20for%20you.%3C%2FP%3E%0A%3CP%3EThese%20two%20lines%2C%20I%20could%20also%20store%20in%20my%20PowerShell%20profile%20I%20use%20for%20demos%2C%20or%20in%20my%20demo%20startup%20script.%20In%20this%20case%2C%20the%20credential%20object%20is%20available%20for%20you%20to%20use.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Use%20Secret%20Store%20Credentials.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F272753iF56B2EC0956311EC%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Use%20Secret%20Store%20Credentials.jpg%22%20alt%3D%22Use%20SecretStore%20credentials%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EUse%20SecretStore%20credentials%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20using%20multiple%20machines%20and%20you%20want%20to%20keep%20your%20passwords%20in%20sync%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkey-vault%2Fgeneral%2Foverview%3FWT.mc_id%3Dmodinfra-16864-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Key%20Vault%3C%2FA%3E%20extension.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EInstall-Module%20Az.KeyVault%0ARegister-SecretVault%20-Module%20Az.KeyVault%20-Name%20AzKV%20-VaultParameters%20%40%7B%20AZKVaultName%20%3D%20%24vaultName%3B%20SubscriptionId%20%3D%20%24subID%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20you%20can%20store%20and%20get%20secrets%20from%20the%20Azure%20Key%20Vault%20and%20you%20can%20simply%20use%20the%20-Vault%20AzKV%20parameter%20instead%20of%20-Vault%20SecretStore.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20this%20blog%20provides%20you%20with%20a%20short%20overview%20of%20how%20you%20can%20leverage%20PowerShell%20SecretManagement%20and%20SecretStore%2C%20to%20store%20your%20passwords%20securely.%20If%20you%20want%20to%20learn%20more%20about%20SecretManagement%20check%20out%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.secretmanagement%3FWT.mc_id%3Dmodinfra-16864-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Docs%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWant%20to%20learn%20how%20to%20install%20PowerShell%207%3F%20Check%20out%20my%20video%20on%20%3CA%20href%3D%22https%3A%2F%2Fchannel9.msdn.com%2FShows%2FIT-Ops-Talk%2FHow-to-install-PowerShell-7%3FWT.mc_id%3Dmodinfra-16864-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Channel%209%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIFRAME%20src%3D%22https%3A%2F%2Fchannel9.msdn.com%2FShows%2FIT-Ops-Talk%2FHow-to-install-PowerShell-7%2Fplayer%3FWT.mc_id%3Dmodinfra-16864-thmaure%22%20width%3D%22960%22%20height%3D%22540%22%20frameborder%3D%220%22%20allowfullscreen%3D%22allowfullscreen%22%20title%3D%22How%20to%20install%20PowerShell%207%20-%20Microsoft%20Channel%209%20Video%22%3E%3C%2FIFRAME%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20also%20highly%20recommend%20that%20you%20read%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F140097%22%20target%3D%22_blank%22%3E%40Pierre%20Roman%3C%2FA%3E%26nbsp%3Bblog%20post%20on%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fleveraging-powershell-secretmanagement-to-generalize-a-demo%2Fba-p%2F2260548%3FWT.mc_id%3Dmodinfra-16864-thmaure%22%20target%3D%22_blank%22%3Eleveraging%20PowerShell%20SecretManagement%20to%20generalize%20a%20demo%20environment%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2272072%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20all%20sometimes%20create%20presentations.%20Often%2C%20we%20need%20to%20use%20credentials%20to%20login%20to%20systems%20for%20example%20PowerShell%20when%20delivering%20demos.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2272072%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EThomas%20Maurer%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎May 16 2021 06:59 AM
Updated by: