Skip to content

Commit

Permalink
Added ShouldProcess to Remove cmdlets, closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
erwindevreugd committed Dec 3, 2017
1 parent b30dc03 commit b24839c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 12 deletions.
17 changes: 14 additions & 3 deletions PSTruPortal/Public/Remove-Credential.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
https://github.com/erwindevreugd/PSThruPortal
#>
function Remove-Credential {
[CmdletBinding()]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact="High"
)]
param (
[Parameter(
Position=0,
Expand Down Expand Up @@ -50,7 +53,13 @@ function Remove-Credential {
ValueFromPipelineByPropertyName=$true,
HelpMessage="The id of the credential to remove."
)]
[int]$CredentialId
[int]$CredentialId,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Forces the removal of the credential with out displaying a should process.')]
[switch]$Force
)

begin {
Expand Down Expand Up @@ -87,7 +96,9 @@ function Remove-Credential {
Headers=$headers;
UseBasicParsing=$true;
}
Invoke-RestMethod @message | Out-Null
if($Force -or $PSCmdlet.ShouldProcess("$Host", "Removing Credential: $($CredentialId)")) {
Invoke-RestMethod @message | Out-Null
}
}

end {
Expand Down
17 changes: 14 additions & 3 deletions PSTruPortal/Public/Remove-Person.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
https://github.com/erwindevreugd/PSThruPortal
#>
function Remove-Person {
[CmdletBinding()]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact="High"
)]
param (
[Parameter(
Position=0,
Expand Down Expand Up @@ -50,7 +53,13 @@ function Remove-Person {
ValueFromPipelineByPropertyName=$true,
HelpMessage="The id of the person to remove."
)]
[int]$PersonId
[int]$PersonId,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Forces the removal of the person with out displaying a should process.')]
[switch]$Force
)

begin {
Expand Down Expand Up @@ -87,7 +96,9 @@ function Remove-Person {
Headers=$headers;
UseBasicParsing=$true;
}
Invoke-RestMethod @message | Out-Null
if($Force -or $PSCmdlet.ShouldProcess("$Host", "Removing Person: $($PersonId)")) {
Invoke-RestMethod @message | Out-Null
}
}

end {
Expand Down
17 changes: 14 additions & 3 deletions PSTruPortal/Public/Remove-Schedule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
https://github.com/erwindevreugd/PSThruPortal
#>
function Remove-Schedule {
[CmdletBinding()]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact="High"
)]
param (
[Parameter(
Position=0,
Expand Down Expand Up @@ -50,7 +53,13 @@ function Remove-Schedule {
ValueFromPipelineByPropertyName=$true,
HelpMessage="The id of the schedule to remove."
)]
[int]$ScheduleId
[int]$ScheduleId,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Forces the removal of the schedule with out displaying a should process.')]
[switch]$Force
)

begin {
Expand Down Expand Up @@ -87,7 +96,9 @@ function Remove-Schedule {
Headers=$headers;
UseBasicParsing=$true;
}
Invoke-RestMethod @message | Out-Null
if($Force -or $PSCmdlet.ShouldProcess("$Host", "Removing Schedule: $($ScheduleId)")) {
Invoke-RestMethod @message | Out-Null
}
}

end {
Expand Down
17 changes: 14 additions & 3 deletions PSTruPortal/Public/Remove.AccessLevel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
https://github.com/erwindevreugd/PSThruPortal
#>
function Remove-AccessLevel {
[CmdletBinding()]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact="High"
)]
param (
[Parameter(
Position=0,
Expand Down Expand Up @@ -50,7 +53,13 @@ function Remove-AccessLevel {
ValueFromPipelineByPropertyName=$true,
HelpMessage="The id of the access level to remove."
)]
[int]$AccessLevelId
[int]$AccessLevelId,

[Parameter(
Mandatory=$false,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Forces the removal of the access level with out displaying a should process.')]
[switch]$Force
)

begin {
Expand Down Expand Up @@ -87,7 +96,9 @@ function Remove-AccessLevel {
Headers=$headers;
UseBasicParsing=$true;
}
Invoke-RestMethod @message | Out-Null
if($Force -or $PSCmdlet.ShouldProcess("$Host", "Removing AccessLevel: $($AccessLevelId)")) {
Invoke-RestMethod @message | Out-Null
}
}

end {
Expand Down

0 comments on commit b24839c

Please sign in to comment.