diff --git a/docs/commands/distributed-engines/Unregister-TssDistributedEngine.md b/docs/commands/distributed-engines/Unregister-TssDistributedEngine.md new file mode 100644 index 00000000..9373bcd3 --- /dev/null +++ b/docs/commands/distributed-engines/Unregister-TssDistributedEngine.md @@ -0,0 +1,120 @@ +# Unregister-TssDistributedEngine + +## SYNOPSIS +Deactivate a Distributed Engine for a Site + +## SYNTAX + +``` +Unregister-TssDistributedEngine [-TssSession] -Id -SiteId [-WhatIf] [-Confirm] + [] +``` + +## 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) + diff --git a/src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1 b/src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1 new file mode 100644 index 00000000..cc2302ed --- /dev/null +++ b/src/functions/distributed-engines/Unregister-TssDistributedEngine.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/tests/distributed-engines/Unregister-TssDistributedEngine.Tests.ps1 b/tests/distributed-engines/Unregister-TssDistributedEngine.Tests.ps1 new file mode 100644 index 00000000..dc24a741 --- /dev/null +++ b/tests/distributed-engines/Unregister-TssDistributedEngine.Tests.ps1 @@ -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' + } + } +} \ No newline at end of file