-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unregister-TssDistributedEngine - new command to deactivate a Distrib…
…uted Engine for a Site
- Loading branch information
Showing
3 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
docs/commands/distributed-engines/Unregister-TssDistributedEngine.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
51 changes: 51 additions & 0 deletions
51
src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/distributed-engines/Unregister-TssDistributedEngine.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
} |