Skip to content

Commit

Permalink
Enable/Disable-TssEventPipeline - new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Aug 1, 2021
1 parent 466cb26 commit 30de5c7
Show file tree
Hide file tree
Showing 7 changed files with 393 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .vscode/tss.code-snippets
Expand Up @@ -774,10 +774,10 @@
"${4:description of example}",
"",
".LINK",
"https://thycotic-ps.github.io/thycotic.secretserver/commands/${2:folder name}",
"https://thycotic-ps.github.io/thycotic.secretserver/commands/${5:folder}/${2}",
"",
".LINK",
"https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/${2}/${5:filename}.ps1",
"https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/${5}/${2}.ps1",
"",
".NOTES",
"Requires TssSession object returned by New-TssSession",
Expand Down Expand Up @@ -832,7 +832,7 @@
" }",
" }",
" \\$invokeParams.Body = \\$${3}Body | ConvertTo-Json -Depth 100",
" if (\\$PSCmdlet.ShouldProcess(\"description: $\", \"$($invokeParams.Method) \\$uri with: `n\\$(\\$invokeParams.Body)\")) {",
" if (\\$PSCmdlet.ShouldProcess(\"description: \\$\", \"\\$(\\$invokeParams.Method) \\$uri with: `n\\$(\\$invokeParams.Body)\")) {",
" Write-Verbose \"\\$(\\$invokeParams.Method) \\$uri with: `n\\$(\\$invokeParams.Body)\"",
" try {",
" \\$restResponse = . \\$InvokeApi @invokeParams",
Expand Down
103 changes: 103 additions & 0 deletions docs/commands/event-pipeline/Disable-TssEventPipeline.md
@@ -0,0 +1,103 @@
# Disable-TssEventPipeline

## SYNOPSIS
Disable an Event Pipeline of an Event Pipeline Policy

## SYNTAX

```
Disable-TssEventPipeline [-TssSession] <Session> -Id <Int32[]> [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Disable an Event Pipeline of an Event Pipeline Policy

## EXAMPLES

### EXAMPLE 1
```
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Disable-TssEventPipeline -TssSession $session -Id 43
```

Disable Event Pipeline 43

## 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
Event Pipeline ID to Disable

```yaml
Type: Int32[]
Parameter Sets: (All)
Aliases: EventPipelineId

Required: True
Position: Named
Default value: None
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

## NOTES
Requires TssSession object returned by New-TssSession

## RELATED LINKS

[https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline/Disable-TssEventPipeline](https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline/Disable-TssEventPipeline)

[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline/Disable-TssEventPipeline.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline/Disable-TssEventPipeline.ps1)

103 changes: 103 additions & 0 deletions docs/commands/event-pipeline/Enable-TssEventPipeline.md
@@ -0,0 +1,103 @@
# Enable-TssEventPipeline

## SYNOPSIS
Enable an Event Pipeline of an Event Pipeline Policy

## SYNTAX

```
Enable-TssEventPipeline [-TssSession] <Session> -Id <Int32[]> [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Enable an Event Pipeline of an Event Pipeline Policy

## EXAMPLES

### EXAMPLE 1
```
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Enable-TssEventPipeline -TssSession $session -Id 43
```

Enable Event Pipeline 43

## 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
Event Pipeline ID to enable

```yaml
Type: Int32[]
Parameter Sets: (All)
Aliases: EventPipelineId

Required: True
Position: Named
Default value: None
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

## NOTES
Requires TssSession object returned by New-TssSession

## RELATED LINKS

[https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline/Enable-TssEventPipeline](https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline/Enable-TssEventPipeline)

[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline/Enable-TssEventPipeline.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline/Enable-TssEventPipeline.ps1)

73 changes: 73 additions & 0 deletions src/functions/event-pipeline/Disable-TssEventPipeline.ps1
@@ -0,0 +1,73 @@
function Disable-TssEventPipeline {
<#
.SYNOPSIS
Disable an Event Pipeline of an Event Pipeline Policy
.DESCRIPTION
Disable an Event Pipeline of an Event Pipeline Policy
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Disable-TssEventPipeline -TssSession $session -Id 43
Disable Event Pipeline 43
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline/Disable-TssEventPipeline
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline/Disable-TssEventPipeline.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,

# Event Pipeline ID to Disable
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[Alias('EventPipelineId')]
[int[]]
$Id
)
begin {
$tssParams = $PSBoundParameters
$invokeParams = . $GetInvokeTssParams $TssSession
}
process {
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)"
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) {
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation
foreach ($pipeline in $Id) {
$uri = $TssSession.ApiUrl, 'event-pipeline', $pipeline, 'activate' -join '/'
$invokeParams.Uri = $uri
$invokeParams.Method = 'PUT'

$DisablePipelineBody = @{ Activate = $false }
$invokeParams.Body = $DisablePipelineBody | ConvertTo-Json
if ($PSCmdlet.ShouldProcess("description: $", "$($invokeParams.Method) $uri with: `n$($invokeParams.Body)")) {
Write-Verbose "$($invokeParams.Method) $uri with: `n$($invokeParams.Body)"
try {
$restResponse = . $InvokeApi @invokeParams
} catch {
Write-Warning 'Issue warning message'
$err = $_
. $ErrorHandling $err
}

if (-not $restResponse) {
Write-Verbose "Event Pipeline [$pipeline] Disabled"
} else {
Write-Warning "Event Pipeline [$pipeline] not successfully Disabled"
}
}
}
} else {
Write-Warning 'No valid session found'
}
}
}
73 changes: 73 additions & 0 deletions src/functions/event-pipeline/Enable-TssEventPipeline.ps1
@@ -0,0 +1,73 @@
function Enable-TssEventPipeline {
<#
.SYNOPSIS
Enable an Event Pipeline of an Event Pipeline Policy
.DESCRIPTION
Enable an Event Pipeline of an Event Pipeline Policy
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Enable-TssEventPipeline -TssSession $session -Id 43
Enable Event Pipeline 43
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline/Enable-TssEventPipeline
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline/Enable-TssEventPipeline.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,

# Event Pipeline ID to enable
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[Alias('EventPipelineId')]
[int[]]
$Id
)
begin {
$tssParams = $PSBoundParameters
$invokeParams = . $GetInvokeTssParams $TssSession
}
process {
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)"
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) {
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation
foreach ($pipeline in $Id) {
$uri = $TssSession.ApiUrl, 'event-pipeline', $pipeline, 'activate' -join '/'
$invokeParams.Uri = $uri
$invokeParams.Method = 'PUT'

$enablePipelineBody = @{ Activate = $true }
$invokeParams.Body = $enablePipelineBody | ConvertTo-Json
if ($PSCmdlet.ShouldProcess("description: $pipeline", "$($invokeParams.Method) $uri with: `n$($invokeParams.Body)")) {
Write-Verbose "$($invokeParams.Method) $uri with: `n$($invokeParams.Body)"
try {
$restResponse = . $InvokeApi @invokeParams
} catch {
Write-Warning 'Issue warning message'
$err = $_
. $ErrorHandling $err
}

if ($restResponse) {
Write-Verbose "Event Pipeline [$pipeline] enabled"
} else {
Write-Warning "Event Pipeline [$pipeline] not successfully enabled"
}
}
}
} else {
Write-Warning 'No valid session found'
}
}
}

0 comments on commit 30de5c7

Please sign in to comment.