diff --git a/src/Thycotic.SecretServer.psm1 b/src/Thycotic.SecretServer.psm1 index 35ff8825..900b8530 100644 --- a/src/Thycotic.SecretServer.psm1 +++ b/src/Thycotic.SecretServer.psm1 @@ -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 * \ No newline at end of file diff --git a/src/functions/Invoke-RestApi.ps1 b/src/functions/Invoke-RestApi.ps1 index 1c818ef8..b6d8e2b6 100644 --- a/src/functions/Invoke-RestApi.ps1 +++ b/src/functions/Invoke-RestApi.ps1 @@ -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 @@ -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, diff --git a/src/functions/auth/New-Session.ps1 b/src/functions/auth/New-Session.ps1 index 498e6434..c2ae11dc 100644 --- a/src/functions/auth/New-Session.ps1 +++ b/src/functions/auth/New-Session.ps1 @@ -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 @@ -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, diff --git a/src/functions/secrets/Get-Secret.ps1 b/src/functions/secrets/Get-Secret.ps1 index 58f324e8..224d802a 100644 --- a/src/functions/secrets/Get-Secret.ps1 +++ b/src/functions/secrets/Get-Secret.ps1 @@ -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 @@ -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,