Skip to content

Commit

Permalink
Unregister-TssDistributedEngine - new command to deactivate a Distrib…
Browse files Browse the repository at this point in the history
…uted Engine for a Site
  • Loading branch information
wsmelton committed Oct 14, 2021
1 parent f5f560b commit d7a3f55
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 0 deletions.
120 changes: 120 additions & 0 deletions docs/commands/distributed-engines/Unregister-TssDistributedEngine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Unregister-TssDistributedEngine

## SYNOPSIS
Deactivate a Distributed Engine for a Site

## SYNTAX

```
Unregister-TssDistributedEngine [-TssSession] <Session> -Id <Int32[]> -SiteId <Int32> [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Deactivate a Distributed Engine for a Site

## EXAMPLES

### EXAMPLE 1
```
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Unregister-TssDistributedEngine -TssSession $session -EngineId 6 -SiteId 5
```

Deactivate Engine ID 6 on Site ID 5

## 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
```
### -Id
Engine ID
```yaml
Type: Int32[]
Parameter Sets: (All)
Aliases: EngineId

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -SiteId
Site ID
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: 0
Accept pipeline input: True (ByPropertyName)
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
### Thycotic.PowerShell.DistributedEngines.EngineActivation
## NOTES
Requires TssSession object returned by New-TssSession
## RELATED LINKS
[https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Unregister-TssDistributedEngine](https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Unregister-TssDistributedEngine)
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function Unregister-TssDistributedEngine {
<#
.SYNOPSIS
Deactivate a Distributed Engine for a Site
.DESCRIPTION
Deactivate a Distributed Engine for a Site
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Unregister-TssDistributedEngine -TssSession $session -EngineId 6 -SiteId 5
Deactivate Engine ID 6 on Site ID 5
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Unregister-TssDistributedEngine
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1
.NOTES
Requires TssSession object returned by New-TssSession
#>
[CmdletBinding(SupportsShouldProcess)]
[OutputType('Thycotic.PowerShell.DistributedEngines.EngineActivation')]
param (
# TssSession object created by New-TssSession for authentication
[Parameter(Mandatory, ValueFromPipeline, Position = 0)]
[Thycotic.PowerShell.Authentication.Session]
$TssSession,

# Engine ID
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[Alias('EngineId')]
[int[]]
$Id,

# Site ID
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[int]
$SiteId
)
begin {
$tssParams = $PSBoundParameters
}
process {
Get-TssInvocation $PSCmdlet.MyInvocation
$tssParams.Add('Status','Deactivate')
Update-TssDistributedEngine @tssParams
}
}
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', 'EngineId', 'SiteId'
[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.DistributedEngines.EngineActivation" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'Thycotic.PowerShell.DistributedEngines.EngineActivation'
}
}
}

0 comments on commit d7a3f55

Please sign in to comment.