Skip to content

Commit

Permalink
Enable/Disable-TssEventPipelinePolicy - new commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Aug 5, 2021
1 parent 13ae3d6 commit 0ad7fa7
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 5 deletions.
103 changes: 103 additions & 0 deletions docs/commands/event-pipeline-policy/Disable-TssEventPipelinePolicy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Disable-TssEventPipelinePolicy

## SYNOPSIS
Disable an Event Pipeline Policy

## SYNTAX

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

## DESCRIPTION
Disable an Event Pipeline Policy

## EXAMPLES

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

Disable Event Pipeline Policy 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: EventPipelinePolicyId

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-policy/Disable-TssEventPipelinePolicy](https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline-policy/Disable-TssEventPipelinePolicy)
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline-policy/Disable-TssEventPipelinePolicy.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline-policy/Disable-TssEventPipelinePolicy.ps1)
103 changes: 103 additions & 0 deletions docs/commands/event-pipeline-policy/Enable-TssEventPipelinePolicy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Enable-TssEventPipelinePolicy

## SYNOPSIS
Enable an Event Pipeline Policy

## SYNTAX

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

## DESCRIPTION
Enable an Event Pipeline Policy

## EXAMPLES

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

Enable Event Pipeline Policy 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: EventPipelinePolicyId

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-policy/Enable-TssEventPipelinePolicy](https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline-policy/Enable-TssEventPipelinePolicy)
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline-policy/Enable-TssEventPipelinePolicy.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline-policy/Enable-TssEventPipelinePolicy.ps1)
7 changes: 4 additions & 3 deletions src/Thycotic.SecretServer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ NestedModules = @('bin\Thycotic.SecretServer.dll')
FunctionsToExport = 'Add-TssEventPipeline', 'Add-TssFolderPermission',
'Add-TssGroupMember', 'Add-TssSecretPermission',
'Add-TssSecretTemplateField', 'Close-TssSecret',
'Disable-TssEventPipeline', 'Disable-TssSecretCheckout',
'Disable-TssSecretEmail', 'Disable-TssUnlimitedAdmin',
'Disable-TssUser', 'Enable-TssEventPipeline',
'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-TssReport',
'Find-TssFolder', 'Find-TssGroup', 'Find-TssReport', 'Find-TssSecret',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
function Disable-TssEventPipelinePolicy {
<#
.SYNOPSIS
Disable an Event Pipeline Policy
.DESCRIPTION
Disable an Event Pipeline Policy
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Disable-TssEventPipelinePolicy -TssSession $session -Id 43
Disable Event Pipeline Policy 43
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline-policy/Disable-TssEventPipelinePolicy
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline-policy/Disable-TssEventPipelinePolicy.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('EventPipelinePolicyId')]
[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 ($policy in $Id) {
$uri = $TssSession.ApiUrl, 'event-pipeline-policy', $policy, '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 disabling Event Pipeline Policy [$policy]"
$err = $_
. $ErrorHandling $err
}

if (-not $restResponse) {
Write-Verbose "Event Pipeline Policy [$policy] Disabled"
} else {
Write-Warning "Event Pipeline Policy [$policy] not successfully Disabled"
}
}
}
} else {
Write-Warning 'No valid session found'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
function Enable-TssEventPipelinePolicy {
<#
.SYNOPSIS
Enable an Event Pipeline Policy
.DESCRIPTION
Enable an Event Pipeline Policy
.EXAMPLE
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred
Enable-TssEventPipelinePolicy -TssSession $session -Id 43
Enable Event Pipeline Policy 43
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/event-pipeline-policy/Enable-TssEventPipelinePolicy
.LINK
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/event-pipeline-policy/Enable-TssEventPipelinePolicy.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('EventPipelinePolicyId')]
[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 ($policy in $Id) {
$uri = $TssSession.ApiUrl, 'event-pipeline-policy', $policy, 'activate' -join '/'
$invokeParams.Uri = $uri
$invokeParams.Method = 'PUT'

$EnablePipelineBody = @{ Activate = $true }
$invokeParams.Body = $EnablePipelineBody | 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 disabling Event Pipeline Policy [$policy]"
$err = $_
. $ErrorHandling $err
}

if (-not $restResponse) {
Write-Verbose "Event Pipeline Policy [$policy] Enabled"
} else {
Write-Warning "Event Pipeline Policy [$policy] not successfully Enabled"
}
}
}
} else {
Write-Warning 'No valid session found'
}
}
}
2 changes: 1 addition & 1 deletion src/functions/event-pipeline/Disable-TssEventPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Disable-TssEventPipeline {
try {
$restResponse = . $InvokeApi @invokeParams
} catch {
Write-Warning 'Issue warning message'
Write-Warning "Issue disabling Event Pipeline [$pipeline]"
$err = $_
. $ErrorHandling $err
}
Expand Down
2 changes: 1 addition & 1 deletion src/functions/event-pipeline/Enable-TssEventPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Enable-TssEventPipeline {
try {
$restResponse = . $InvokeApi @invokeParams
} catch {
Write-Warning 'Issue warning message'
Write-Warning "Issue enabling Event Pipeline [$pipeline]"
$err = $_
. $ErrorHandling $err
}
Expand Down
Loading

0 comments on commit 0ad7fa7

Please sign in to comment.