|
| 1 | +<# |
| 2 | +Copyright 2017 Dominique Broeglin |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +#> |
| 16 | + |
| 17 | +function Remove-NSSystemFile { |
| 18 | + <# |
| 19 | + .SYNOPSIS |
| 20 | + Remove a system file from the NetScaler. |
| 21 | +
|
| 22 | + .DESCRIPTION |
| 23 | + Remove a system file from the NetScaler. |
| 24 | +
|
| 25 | + .EXAMPLE |
| 26 | + Remove-NSSystemFile -Name 'test.tgz' |
| 27 | +
|
| 28 | + Remove a system file called 'test.tgz' from the NetScaler. |
| 29 | +
|
| 30 | + .PARAMETER Session |
| 31 | + The NetScaler session object. |
| 32 | +
|
| 33 | + .PARAMETER Name |
| 34 | + Name of the system file to remove. |
| 35 | +
|
| 36 | + .PARAMETER FileLocation |
| 37 | + Location of the system file to remove. |
| 38 | +
|
| 39 | + .PARAMETER Force |
| 40 | + Suppress confirmation when removing a system file. |
| 41 | + #> |
| 42 | + [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact='Medium')] |
| 43 | + param( |
| 44 | + $Session = $script:session, |
| 45 | + |
| 46 | + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] |
| 47 | + [Alias('Filename')] |
| 48 | + [string[]]$Name, |
| 49 | + |
| 50 | + [Parameter(Mandatory)] |
| 51 | + [string]$FileLocation, |
| 52 | + |
| 53 | + [switch]$Force |
| 54 | + ) |
| 55 | + |
| 56 | + begin { |
| 57 | + _AssertSessionActive |
| 58 | + } |
| 59 | + |
| 60 | + process { |
| 61 | + foreach ($item in $Name) { |
| 62 | + if ($Force -or $PSCmdlet.ShouldProcess($item, "Delete file $FileLocation/$Name")) { |
| 63 | + _InvokeNSRestApi -Session $Session -Method DELETE -Type systemfile -Resource $item -Action delete -Arguments @{ filelocation = $FileLocation } |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments