Skip to content

Commit d0a75af

Browse files
authored
Merge pull request #72 from dbroeglin/feature/better-housekeeping
Added Remove-NSSystemFile, Get-NSHardware and corrected Get-NSSystemFile
2 parents e3ec9fd + a4004dc commit d0a75af

File tree

6 files changed

+129
-11
lines changed

6 files changed

+129
-11
lines changed

NetScaler/NetScaler.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ FunctionsToExport = @(
112112
'Get-NSDnsNameServer',
113113
'Get-NSDnsSuffix',
114114
'Get-NSFeature',
115+
'Get-NSHardware',
115116
'Get-NSHostname',
116117
'Get-NSIPResource',
117118
'Get-NSIP6Resource',
@@ -190,6 +191,7 @@ FunctionsToExport = @(
190191
'Remove-NSResponderAction',
191192
'Remove-NSSSLCertificateLink',
192193
'Remove-NSSSLProfile',
194+
'Remove-NSSystemFile',
193195
'Remove-NSVPNSessionPolicy',
194196
'Remove-NSVPNSessionProfile',
195197
'Restart-NetScaler',

NetScaler/Private/_InvokeNSRestApiGet.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function _InvokeNSRestApiGet {
4646

4747
if ($Name.Count -gt 0) {
4848
foreach ($item in $Name) {
49-
$response = _InvokeNSRestApi -Session $Session -Method Get -Type $Type -Resource $item -Action Get -Filters $Filters
49+
$response = _InvokeNSRestApi -Session $Session -Method Get -Type $Type -Resource $item -Action Get -Filters $Filters -Arguments $Arguments
5050
if ($response.errorcode -ne 0) { throw $response }
5151
if ($Response.psobject.properties.name -contains $Type) {
5252
$response.$Type
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 Get-NSHardware {
18+
<#
19+
.SYNOPSIS
20+
Gets the hardware information for the NetScaler appliance.
21+
22+
.DESCRIPTION
23+
Gets the hardware information for the NetScaler appliance.
24+
25+
.EXAMPLE
26+
Get-NSHardware
27+
28+
Get the NetScaler hardware information.
29+
30+
.EXAMPLE
31+
Get-NSHardware | Select-Object -ExpandProperty host
32+
33+
Get the NetScaler host ID (used for licenses). For some reason the 'hostid' property contains
34+
another, numeric, value.
35+
36+
.PARAMETER Session
37+
The NetScaler session object.
38+
39+
#>
40+
[cmdletbinding()]
41+
param(
42+
$Session = $script:session
43+
)
44+
45+
begin {
46+
_AssertSessionActive
47+
}
48+
49+
process {
50+
_InvokeNSRestApiGet -Session $Session -Type nshardware
51+
}
52+
}

NetScaler/Public/Get-NSSystemFile.ps1

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ function Get-NSSystemFile {
5252
param(
5353
$Session = $Script:Session,
5454

55-
[Parameter(Position=0, ParameterSetName='get')]
55+
[Parameter(Position=0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
5656
[string[]]$Name = @(),
5757

5858
[Parameter(ParameterSetName='search')]
59-
6059
[string]$Filename,
6160

62-
[Parameter(ParameterSetName='search')]
63-
61+
[Parameter(Mandatory)]
6462
[string]$FileLocation
6563
)
6664

@@ -70,13 +68,12 @@ function Get-NSSystemFile {
7068

7169
process {
7270
# Contruct a filter hash if we specified any filters
73-
$Filters = @{}
71+
$Filters = @{
72+
filelocation = $FileLocation
73+
}
7474
if ($PSBoundParameters.ContainsKey('Filename')) {
7575
$Filters['filename'] = $Filename
7676
}
77-
if ($PSBoundParameters.ContainsKey('FileLocation')) {
78-
$Filters['filelocation'] = $FileLocation
79-
}
8077
_InvokeNSRestApiGet -Session $Session -Type systemfile -Name $Name -Arguments $Filters
8178
}
82-
}
79+
}

NetScaler/Public/Install-NSLicense.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function Install-NSLicense {
4646
if (Test-Path -Path $_) {
4747
$true
4848
} else {
49-
throw 'Cannot file license file. Path does not exist.'
49+
throw 'Cannot find license file. Path does not exist.'
5050
}
5151
})]
5252
[string]$Path,
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)