Skip to content

Commit

Permalink
module - correct command alias reference and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed May 24, 2021
1 parent a898187 commit 95f4656
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/Thycotic.SecretServer.psm1
Expand Up @@ -62,9 +62,9 @@ $script:PSModuleRoot = $PSScriptRoot
$shortcuts = @{
'gts' = 'Get-TssSecret'
'nts' = 'New-TssSession'
'itra' = 'Invoke-TssRestApi'
'ira' = 'Invoke-TssRestApi'
}
foreach ($_ in $shortcuts.GetEnumerator()) {
New-Alias -Name $_.Key -Value $_.Value
New-Alias -Name $_.Key -Value $_.Value -Force
}
Export-ModuleMember -Alias * -Function * -Cmdlet *
10 changes: 8 additions & 2 deletions src/functions/Invoke-RestApi.ps1
Expand Up @@ -12,6 +12,12 @@ function Invoke-RestApi {
Performs request to the URI specified, returning all secrets the current credential has access to view (minimum).
.EXAMPLE
$session = tssnts https://alpha $ssCred
tssira "$($session.ApiUrl)/secrets" $session.AccessToken
Performs request to the URI specified, returning all secrets the current credential has access to view (minimum) using alias names for each function.
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/Invoke-TssRestApi
Expand All @@ -24,13 +30,13 @@ function Invoke-RestApi {
[Cmdletbinding()]
param(
# Secret Server REST API URL
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Parameter(Mandatory,ValueFromPipelineByPropertyName, Position = 0)]
[Alias('Url')]
[uri]
$Uri,

# Valid Access Token issued by Secret Server
[Parameter(ValueFromPipelineByPropertyName)]
[Parameter(ValueFromPipelineByPropertyName, Position = 1)]
[Alias('PAT')]
[string]
$PersonalAccessToken,
Expand Down
14 changes: 7 additions & 7 deletions src/functions/auth/New-Session.ps1
Expand Up @@ -8,32 +8,32 @@ function New-Session {
.EXAMPLE
$cred = [PSCredential]::new('apiuser',(ConvertTo-SecureString -String "Fancy%$#Passwod" -AsPlainText -Force))
New-TssSession -SecretServer https://ssvault.com/SecretServer -Credential $cred
$session = New-TssSession -SecretServer https://ssvault.com/SecretServer -Credential $cred
A PSCredential is created for the apiuser account. The internal TssSession is updated upon successful authentication, and then output to the console.
.EXAMPLE
$token = .\tss.exe -kd c:\secretserver\module_testing\ -cd c:\secretserver\module_testing
$tssSession = New-TssSession -SecretServer https://ssvault.com/SecretServer -AccessToken $token
$session = New-TssSession -SecretServer https://ssvault.com/SecretServer -AccessToken $token
A token is requested via Client SDK (after proper init has been done)
TssSession object is created with minimum properties required by the module.
Note that this use case, SessionRefresh and SessionExpire are not supported
.EXAMPLE
New-TssSession -SecretServer https://ssvault.com/SecretServer -Credential (Get-Credential apiuser)
$session = New-TssSession -SecretServer https://ssvault.com/SecretServer -Credential (Get-Credential apiuser)
A prompt to enter the password for the apiuser is given by PowerShell. Upon successful authentication the response from the oauth2/token endpoint is output to the console.
.EXAMPLE
$secretCred = [pscredential]::new('ssadmin',(ConvertTo-SecureString -String 'F@#R*(@#$SFSDF1234' -AsPlainText -Force)))
$session = nts https://ssvault.com/SecretServer $secretCred
$session = tssnts https://ssvault.com/SecretServer $secretCred
Create a credential object
Use the alias nts to create a session object
.EXAMPLE
$session = nts https://ssvault.com/SecretServer -UseWindowsAuth
$session = tssnts https://ssvault.com/SecretServer -UseWindowsAuth
Create a session object utilizing Windows Integrated Authentication (IWA)
Use the alias nts to create a session object
Expand All @@ -59,13 +59,13 @@ function New-Session {
# Secret Server URL
[Parameter(Mandatory,ParameterSetName = 'new', Position = 0)]
[Parameter(Mandatory,ParameterSetName = 'sdk', Position = 0)]
[Parameter(Mandatory,ParameterSetName = 'winauth', Position = 1)]
[Parameter(Mandatory,ParameterSetName = 'winauth', Position = 0)]
[Parameter(Mandatory,ParameterSetName = 'clientSdk')]
[uri]
$SecretServer,

# Specify a Secret Server user account.
[Parameter(Mandatory,ParameterSetName = 'new')]
[Parameter(Mandatory,ParameterSetName = 'new', Position = 1)]
[PSCredential]
[Management.Automation.CredentialAttribute()]
$Credential,
Expand Down
9 changes: 7 additions & 2 deletions src/functions/secrets/Get-Secret.ps1
Expand Up @@ -42,6 +42,12 @@ function Get-Secret {
Get Secret via absolute path.
.EXAMPLE
$session = tssnts https://alpha $ssCred
(tssgts $session 330).GetCredential($null,'username','password')
Get PSCredential object for Secret ID 330, using alias for the function names
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/Get-TssSecret
Expand All @@ -60,8 +66,7 @@ function Get-Secret {
$TssSession,

# Secret ID to retrieve
[Parameter(ParameterSetName = 'secret')]
[Parameter(ParameterSetName = 'all')]
[Parameter(Mandatory,Position = 0)]
[Alias("SecretId")]
[int[]]
$Id,
Expand Down

0 comments on commit 95f4656

Please sign in to comment.