Skip to content

Commit

Permalink
Get-TssConfigurationAutoExport - new command
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Aug 23, 2021
1 parent b2dd116 commit 5649af6
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/commands/configurations/Get-TssConfigurationAutoExport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Get-TssConfigurationAutoExport

## SYNOPSIS
Get the Automatic Export configuration

## SYNTAX

```
Get-TssConfigurationAutoExport [-TssSession] <Session> [<CommonParameters>]
```

## DESCRIPTION
Get the Automatic Export configuration

## EXAMPLES

### EXAMPLE 1
```
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Get-TssConfigurationAutomaticExport -TssSession $session -Id 42
```

Return the Automatic Export configuration settings

## PARAMETERS

### -TssSession
TssSession object created by New-TssSession for authentication

```yaml
Type: Session
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Thycotic.PowerShell.Configuration.AutomaticExport
## NOTES
Requires TssSession object returned by New-TssSession
## RELATED LINKS
[https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Get-TssConfigurationAutoExport](https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Get-TssConfigurationAutoExport)
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Get-TssConfigurationAutoExport.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Get-TssConfigurationAutoExport.ps1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Threading.Tasks;
using System.Management.Automation;
using System.Management.Automation.Runspaces;

namespace Thycotic.PowerShell.Configuration
{
public class AutomaticExport
{
public bool EnableAutoExport { get; set; }
public bool ExportChildFolders { get; set; }
public bool ExportFolderPaths { get; set; }
public int ExportPasswordSecretId { get; set; }
public string ExportPath { get; set; }
public bool ExportTotpSettings { get; set; }
public int FolderId { get; set; }
public int FrequencyDays { get; set; }
public DateTime? LastExported { get; set; }
public int UserId { get; set; }
}
}
62 changes: 62 additions & 0 deletions src/functions/configurations/Get-TssConfigurationAutoExport.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function Get-TssConfigurationAutoExport {
<#
.SYNOPSIS
Get the Automatic Export configuration
.DESCRIPTION
Get the Automatic Export configuration
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Get-TssConfigurationAutomaticExport -TssSession $session -Id 42
Return the Automatic Export configuration settings
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Get-TssConfigurationAutoExport
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Get-TssConfigurationAutoExport.ps1
.NOTES
Requires TssSession object returned by New-TssSession
#>
[CmdletBinding()]
[OutputType('Thycotic.PowerShell.Configuration.AutomaticExport')]
param (
# TssSession object created by New-TssSession for authentication
[Parameter(Mandatory,ValueFromPipeline,Position = 0)]
[Thycotic.PowerShell.Authentication.Session]
$TssSession
)
begin {
$tssParams = $PSBoundParameters
$invokeParams = . $GetInvokeApiParams $TssSession
}
process {
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)"
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) {
. $CheckVersion $TssSession '11.0.000005' $PSCmdlet.MyInvocation
$restResponse = $null
$uri = $TssSession.ApiUrl, 'configuration', 'auto-export' -join '/'
$invokeParams.Uri = $uri
$invokeParams.Method = 'GET'

Write-Verbose "Performing the operation $($invokeParams.Method) $($invokeParams.Uri)"
try {
$apiResponse = Invoke-TssApi @invokeParams
$restResponse = . $ProcessResponse $apiResponse
} catch {
Write-Warning "Issue getting Automatic Export configuration"
$err = $_
. $ErrorHandling $err
}

if ($restResponse) {
[Thycotic.PowerShell.Configuration.AutomaticExport]$restResponse
}
} else {
Write-Warning "No valid session found"
}
}
}
24 changes: 24 additions & 0 deletions tests/configurations/Get-TssConfigurationAutoExport.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BeforeDiscovery {
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf
}
Describe "$commandName verify parameters" {
BeforeDiscovery {
[object[]]$knownParameters = 'TssSession'
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')).Parameters.Keys
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru
}
Context "Verify parameters" -Foreach @{currentParams = $currentParams } {
It "$commandName should contain <_> parameter" -TestCases $knownParameters {
$_ -in $currentParams | Should -Be $true
}
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters {
$_ | Should -BeNullOrEmpty
}
}
Context "Command specific details" {
It "$commandName should set OutputType to Thycotic.PowerShell.Configuration.AutomaticExport" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'Thycotic.PowerShell.Configuration.AutomaticExport'
}
}
}

0 comments on commit 5649af6

Please sign in to comment.