Skip to content

Commit

Permalink
Start-TssConfigurationBackup - new command
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Aug 30, 2021
1 parent 7c5bb0c commit 2991b7e
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 83 deletions.
88 changes: 88 additions & 0 deletions docs/commands/configurations/Start-TssConfigurationBackup.md
@@ -0,0 +1,88 @@
# Start-TssConfigurationBackup

## SYNOPSIS
Start the database backup as configured

## SYNTAX

```
Start-TssConfigurationBackup [-TssSession] <Session> [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Start the database backup as configured

## EXAMPLES

### EXAMPLE 1
```
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Start-TssConfigurationBackup -TssSession $session
```

Run the backup for the Secret Server as configured

## 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
```

### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
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

## NOTES
Requires TssSession object returned by New-TssSession

## RELATED LINKS

[https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Start-TssConfigurationBackup](https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Start-TssConfigurationBackup)

[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Start-TssConfigurationBackup.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Start-TssConfigurationBackup.ps1)

168 changes: 85 additions & 83 deletions src/Thycotic.SecretServer.psd1
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Shawn Melton
#
# Generated on: 8/26/2021
# Generated on: 8/30/2021
#

@{
Expand Down Expand Up @@ -69,88 +69,90 @@ FormatsToProcess = 'Thycotic.SecretServer.Format.ps1xml'
NestedModules = @('bin\Thycotic.SecretServer.dll')

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-TssEventPipeline', 'Add-TssFolderPermission',
'Add-TssGroupMember', 'Add-TssSecretPermission',
'Add-TssSecretTemplateField', 'Close-TssSecret', 'Close-TssSession',
'Disable-TssEventPipeline', 'Disable-TssEventPipelinePolicy',
'Disable-TssSecretCheckout', 'Disable-TssSecretEmail',
'Disable-TssUnlimitedAdmin', 'Disable-TssUser',
'Enable-TssEventPipeline', 'Enable-TssEventPipelinePolicy',
'Enable-TssSecretCheckout', 'Enable-TssSecretEmail',
'Enable-TssUnlimitedAdmin', 'Enable-TssUser',
'Export-TssAutoExportStorageItem', 'Export-TssReport',
'Find-TssFolder', 'Find-TssGroup', 'Find-TssReport', 'Find-TssSecret',
'Find-TssUser', 'Get-TssConfiguration',
'Get-TssConfigurationAutoExport',
'Get-TssConfigurationLocalUserPassword',
'Get-TssConfigurationLogin', 'Get-TssConfigurationRpc',
'Get-TssConfigurationSaml', 'Get-TssConfigurationSecretIndexer',
'Get-TssConfigurationSecurity', 'Get-TssConfigurationSiteConnector',
'Get-TssEventPipeline', 'Get-TssEventPipelinePolicy',
'Get-TssEventPipelinePolicyActivity', 'Get-TssEventPipelineRun',
'Get-TssFolder', 'Get-TssFolderAudit', 'Get-TssFolderPermission',
'Get-TssFolderState', 'Get-TssGroup', 'Get-TssGroupMember',
'Get-TssGroupRole', 'Get-TssGroupUser', 'Get-TssMetadataField',
'Get-TssReport', 'Get-TssReportCategory', 'Get-TssReportParameter',
'Get-TssReportSchedule', 'Get-TssRpcAssociatedSecret',
'Get-TssRpcPasswordType', 'Get-TssScript', 'Get-TssSecret',
'Get-TssSecretAccessRequest', 'Get-TssSecretAccessRequestOption',
'Get-TssSecretAccessRequestSecret', 'Get-TssSecretAttachment',
'Get-TssSecretAudit', 'Get-TssSecretDependency',
'Get-TssSecretDependencyGroup', 'Get-TssSecretDependencyRunStatus',
'Get-TssSecretDependencyStub', 'Get-TssSecretDependencyTemplate',
'Get-TssSecretField', 'Get-TssSecretHeartbeatStatus',
'Get-TssSecretHook', 'Get-TssSecretHookStub',
'Get-TssSecretPasswordStatus', 'Get-TssSecretPolicy',
'Get-TssSecretSetting', 'Get-TssSecretState', 'Get-TssSecretStub',
'Get-TssSecretSummary', 'Get-TssSecretTemplate',
'Get-TssSecretTemplateFolder', 'Get-TssSite', 'Get-TssUser',
'Get-TssUserAudit', 'Get-TssUserGroup', 'Get-TssUserOwner',
'Get-TssUserRole', 'Get-TssUserRoleAssigned', 'Get-TssVersion',
'Initialize-TssSdkClient', 'Invoke-TssReport', 'Invoke-TssRestApi',
'Invoke-TssSecretGeneratePassword', 'Lock-TssUser', 'New-TssFolder',
'New-TssFolderPermission', 'New-TssGroup', 'New-TssMetadataField',
'New-TssReport', 'New-TssReportSchedule', 'New-TssScript',
'New-TssSecret', 'New-TssSecretDependency',
'New-TssSecretDependencyGroup', 'New-TssSecretHook',
'New-TssSecretPermission', 'New-TssSecretTemplate',
'New-TssSecretTemplateField', 'New-TssSession', 'New-TssUser',
'Open-TssSecret', 'Remove-TssEventPipeline', 'Remove-TssFolder',
'Remove-TssFolderPermission', 'Remove-TssFolderTemplate',
'Remove-TssGroupMember', 'Remove-TssMetadata', 'Remove-TssReport',
'Remove-TssReportCategory', 'Remove-TssReportSchedule',
'Remove-TssSecret', 'Remove-TssSecretDependency',
'Remove-TssSecretHook', 'Remove-TssSecretPermission',
'Remove-TssUserPii', 'Reset-TssUserPassword', 'Restore-TssSecret',
'Revoke-TssSecret', 'Search-TssAutoExportStorage',
'Search-TssConfigurationAudit', 'Search-TssDirectoryServiceDomain',
'Search-TssDistributedEngineSite', 'Search-TssEventPipeline',
'Search-TssEventPipelinePolicy', 'Search-TssFolder',
'Search-TssFolderPermission', 'Search-TssGroup', 'Search-TssMetadata',
'Search-TssMetadataHistory', 'Search-TssMetadataSection',
'Search-TssReport', 'Search-TssReportSchedule', 'Search-TssRole',
'Search-TssRpcPasswordType', 'Search-TssScript', 'Search-TssSecret',
'Search-TssSecretAccessRequest', 'Search-TssSecretDependency',
'Search-TssSecretHook', 'Search-TssSecretPermission',
'Search-TssSecretPolicy', 'Search-TssSecretTemplate',
'Search-TssSystemLog', 'Search-TssUser', 'Search-TssWorkflowTemplate',
'Set-TssConfigurationAutoExport', 'Set-TssConfigurationGeneral',
'Set-TssFolder', 'Set-TssSecret', 'Set-TssSecretExpiration',
'Set-TssSecretField', 'Set-TssSecretPolicy',
'Set-TssSecretRpcAssociated', 'Set-TssSecretRpcPrivileged',
'Set-TssSecretSecurity', 'Set-TssSecretTemplate',
'Show-TssCurrentUser', 'Start-TssDiscovery',
'Start-TssSecretChangePassword', 'Start-TssSecretDependency',
'Start-TssSecretHeartbeat', 'Stop-TssSecretChangePassword',
'Test-TssFolderAction', 'Test-TssSdkClient', 'Test-TssSecretAction',
'Test-TssSecretState', 'Test-TssSession', 'Test-TssVersion',
'Unlock-TssUser', 'Update-TssFolder', 'Update-TssFolderPermission',
'Update-TssGroupMember', 'Update-TssMetadataField',
'Update-TssMetadataSection', 'Update-TssSecret',
'Update-TssSecretAccessRequest', 'Update-TssSecretHook',
'Update-TssSecretPermission', 'Update-TssSecretPolicy',
'Update-TssSecretRdpLauncherSetting',
'Update-TssSecretTemplateField', 'Update-TssUser',
FunctionsToExport = 'Add-TssEventPipeline', 'Add-TssFolderPermission',
'Add-TssGroupMember', 'Add-TssSecretPermission',
'Add-TssSecretTemplateField', 'Close-TssSecret', 'Close-TssSession',
'Disable-TssEventPipeline', 'Disable-TssEventPipelinePolicy',
'Disable-TssSecretCheckout', 'Disable-TssSecretEmail',
'Disable-TssUnlimitedAdmin', 'Disable-TssUser',
'Enable-TssEventPipeline', 'Enable-TssEventPipelinePolicy',
'Enable-TssSecretCheckout', 'Enable-TssSecretEmail',
'Enable-TssUnlimitedAdmin', 'Enable-TssUser',
'Export-TssAutoExportStorageItem', 'Export-TssReport',
'Find-TssFolder', 'Find-TssGroup', 'Find-TssReport', 'Find-TssSecret',
'Find-TssUser', 'Get-TssConfiguration',
'Get-TssConfigurationAutoExport', 'Get-TssConfigurationBackup',
'Get-TssConfigurationLocalUserPassword',
'Get-TssConfigurationLogin', 'Get-TssConfigurationRpc',
'Get-TssConfigurationSaml', 'Get-TssConfigurationSecretIndexer',
'Get-TssConfigurationSecurity', 'Get-TssConfigurationSiteConnector',
'Get-TssEventPipeline', 'Get-TssEventPipelinePolicy',
'Get-TssEventPipelinePolicyActivity', 'Get-TssEventPipelineRun',
'Get-TssFolder', 'Get-TssFolderAudit', 'Get-TssFolderPermission',
'Get-TssFolderState', 'Get-TssGroup', 'Get-TssGroupMember',
'Get-TssGroupRole', 'Get-TssGroupUser', 'Get-TssMetadataField',
'Get-TssReport', 'Get-TssReportCategory', 'Get-TssReportParameter',
'Get-TssReportSchedule', 'Get-TssRpcAssociatedSecret',
'Get-TssRpcPasswordType', 'Get-TssScript', 'Get-TssSecret',
'Get-TssSecretAccessRequest', 'Get-TssSecretAccessRequestOption',
'Get-TssSecretAccessRequestSecret', 'Get-TssSecretAttachment',
'Get-TssSecretAudit', 'Get-TssSecretDependency',
'Get-TssSecretDependencyGroup', 'Get-TssSecretDependencyRunStatus',
'Get-TssSecretDependencyStub', 'Get-TssSecretDependencyTemplate',
'Get-TssSecretField', 'Get-TssSecretHeartbeatStatus',
'Get-TssSecretHook', 'Get-TssSecretHookStub',
'Get-TssSecretPasswordStatus', 'Get-TssSecretPolicy',
'Get-TssSecretSetting', 'Get-TssSecretState', 'Get-TssSecretStub',
'Get-TssSecretSummary', 'Get-TssSecretTemplate',
'Get-TssSecretTemplateFolder', 'Get-TssSite', 'Get-TssUser',
'Get-TssUserAudit', 'Get-TssUserGroup', 'Get-TssUserOwner',
'Get-TssUserRole', 'Get-TssUserRoleAssigned', 'Get-TssVersion',
'Initialize-TssSdkClient', 'Invoke-TssReport', 'Invoke-TssRestApi',
'Invoke-TssSecretGeneratePassword', 'Lock-TssUser', 'New-TssFolder',
'New-TssFolderPermission', 'New-TssGroup', 'New-TssMetadataField',
'New-TssReport', 'New-TssReportSchedule', 'New-TssScript',
'New-TssSecret', 'New-TssSecretDependency',
'New-TssSecretDependencyGroup', 'New-TssSecretHook',
'New-TssSecretPermission', 'New-TssSecretPolicy',
'New-TssSecretTemplate', 'New-TssSecretTemplateField',
'New-TssSession', 'New-TssUser', 'Open-TssSecret',
'Remove-TssEventPipeline', 'Remove-TssFolder',
'Remove-TssFolderPermission', 'Remove-TssFolderTemplate',
'Remove-TssGroupMember', 'Remove-TssMetadata', 'Remove-TssReport',
'Remove-TssReportCategory', 'Remove-TssReportSchedule',
'Remove-TssSecret', 'Remove-TssSecretDependency',
'Remove-TssSecretHook', 'Remove-TssSecretPermission',
'Remove-TssUserPii', 'Reset-TssUserPassword', 'Restore-TssSecret',
'Revoke-TssSecret', 'Search-TssAutoExportStorage',
'Search-TssConfigurationAudit', 'Search-TssConfigurationBackupLog',
'Search-TssDirectoryServiceDomain',
'Search-TssDistributedEngineSite', 'Search-TssEventPipeline',
'Search-TssEventPipelinePolicy', 'Search-TssFolder',
'Search-TssFolderPermission', 'Search-TssGroup', 'Search-TssMetadata',
'Search-TssMetadataHistory', 'Search-TssMetadataSection',
'Search-TssReport', 'Search-TssReportSchedule', 'Search-TssRole',
'Search-TssRpcPasswordType', 'Search-TssScript', 'Search-TssSecret',
'Search-TssSecretAccessRequest', 'Search-TssSecretDependency',
'Search-TssSecretHook', 'Search-TssSecretPermission',
'Search-TssSecretPolicy', 'Search-TssSecretTemplate',
'Search-TssSystemLog', 'Search-TssUser', 'Search-TssWorkflowTemplate',
'Set-TssConfigurationAutoExport', 'Set-TssConfigurationGeneral',
'Set-TssFolder', 'Set-TssSecret', 'Set-TssSecretExpiration',
'Set-TssSecretField', 'Set-TssSecretPolicy',
'Set-TssSecretRpcAssociated', 'Set-TssSecretRpcPrivileged',
'Set-TssSecretSecurity', 'Set-TssSecretTemplate',
'Show-TssCurrentUser', 'Start-TssConfigurationBackup',
'Start-TssDiscovery', 'Start-TssSecretChangePassword',
'Start-TssSecretDependency', 'Start-TssSecretHeartbeat',
'Stop-TssSecretChangePassword', 'Test-TssFolderAction',
'Test-TssSdkClient', 'Test-TssSecretAction', 'Test-TssSecretState',
'Test-TssSession', 'Test-TssVersion', 'Unlock-TssUser',
'Update-TssFolder', 'Update-TssFolderPermission',
'Update-TssGroupMember', 'Update-TssMetadataField',
'Update-TssMetadataSection', 'Update-TssSecret',
'Update-TssSecretAccessRequest', 'Update-TssSecretHook',
'Update-TssSecretPermission', 'Update-TssSecretRdpLauncherSetting',
'Update-TssSecretTemplateField', 'Update-TssUser',
'Update-TssUserPassword', 'Write-TssSecretAccessRequestViewComment'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
Expand Down
60 changes: 60 additions & 0 deletions src/functions/configurations/Start-TssConfigurationBackup.ps1
@@ -0,0 +1,60 @@
function Start-TssConfigurationBackup {
<#
.SYNOPSIS
Start the database backup as configured
.DESCRIPTION
Start the database backup as configured
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Start-TssConfigurationBackup -TssSession $session
Run the backup for the Secret Server as configured
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/configurations/Start-TssConfigurationBackup
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/configurations/Start-TssConfigurationBackup.ps1
.NOTES
Requires TssSession object returned by New-TssSession
#>
[CmdletBinding(SupportsShouldProcess)]
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 '10.9.000064' $PSCmdlet.MyInvocation
$uri = $TssSession.ApiUrl, 'configuration', 'backup', 'run-now' -join '/'
$invokeParams.Uri = $uri
$invokeParams.Method = 'POST'

if (-not $PSCmdlet.ShouldProcess("SecretId: $user", "$($invokeParams.Method) $($invokeParams.Uri)")) { return }
Write-Verbose "Performing the operation: $($invokeParams.Method) $($invokeParams.Uri)"
try {
$apiResponse = Invoke-TssApi @invokeParams
$restResponse = . $ProcessResponse $apiResponse
} catch {
$err = $_
. $ErrorHandling $err
}

if ($restResponse) {
Write-Verbose "Database Backup started successfully"
}
} else {
Write-Warning 'No valid session found'
}
}
}
19 changes: 19 additions & 0 deletions tests/configurations/Start-TssConfigurationBackup.Tests.ps1
@@ -0,0 +1,19 @@
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
}
}
}

0 comments on commit 2991b7e

Please sign in to comment.