MicrosoftDocs / PowerShell-Docs-Modules

Documentation for modules maintained by the PowerShell team
https://learn.microsoft.com/powershell/utility-modules
Creative Commons Attribution 4.0 International
29 stars 44 forks source link

Set-Secret - expand examples to cover more scenarios and options #12

Closed wsmelton closed 2 years ago

wsmelton commented 3 years ago

This command's current examples do not provide enough detail on how it can be used. Example 3 and 4 for example shows using $targetToken as the value of a secret but does not show what it contains or how it was created.

I would propose to add an example for each type of data that can be added, and cover the usage of the various parameters. (e.g. -SecureStringSecret, -Secret, how do you create a PSCredential and store it; then return it).


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

sdwheeler commented 3 years ago

@SydneyhSmith @PaulHigin Can we get some more examples?

@wsmelton Do you have examples you would like to contribute?

sdwheeler commented 3 years ago

@sdwheeler Look at pester tests for some possible examples.

wsmelton commented 3 years ago

You are more than happy to use ones from here that I published: https://thycotic-ps.github.io/thycotic.secretserver/docs/authentication/#example-usage

# Install-Module Microsoft.PowerShell.SecretManagement -Scope AllUsers -Force
Import-Module Microsoft.PowerShell.SecretStore, Microsoft.PowerShell.SecretManagement

<# First time register the SecretStore vault as the default #>
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Register-SecretVault -Name scripts -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault

<# See two vaults are created #>
Get-SecretVault

Set-SecretVaultDefault -Name scripts

<# Unregistered/remove a vault #>
UnRegister-SecretVault SecretStore

# Store a password
Set-Secret -Name apidemoPwd -SecureStringSecret (ConvertTo-SecureString 'P@ssword$01' -AsPlainText -Force)

# Store a full Credential object
$cred = [pscredential]::new('apidemo',(ConvertTo-SecureString 'P@ssword$01' -AsPlainText -Force))
Set-Secret -Name apidemoCred -Secret $cred

# use stored password for authentication

# Get the SecureString created for apidemo account
$Cred = [pscredential]::new('apidemo',(Get-Secret apidemoPwd))

# vs full credential being stored
$Cred = Get-Secret apidemo
PaulHigin commented 3 years ago

This sounds like an ask for a 'about_SecretManagement' document. It is difficult to provide useful scenario examples in a help file for a single cmdlet. In the 'about_SecretManagement' document, we could provide basic end-to-end scenario examples that demonstrate how SecretManagement can be used. But these examples would be contrived. Ideally, community members would experiment with SecretManagement, find unique uses in their individual scenarios, and blog about it. I feel community blogs about real life solutions would be much more useful.

But I'll start work on a 'about_SecretManagement' document mark down file.

Of course if there are obvious holes in our cmdlet help documentation, we should address them. You can create an issue at the SecretManagement repo, and even better provide a pull request with updated help.

sdwheeler commented 2 years ago

New docs published.