Skip to content

Commit 28bd25c

Browse files
committed
Fix parameter names in comment based help
Minor code-style changes
1 parent 363ec09 commit 28bd25c

File tree

4 files changed

+117
-141
lines changed

4 files changed

+117
-141
lines changed

NetScaler/NetScaler.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ FunctionsToExport = @(
138138
'Get-NSLBVirtualServerTrafficPolicyBinding',
139139
'Get-NSLDAPAuthenticationPolicy',
140140
'Get-NSLDAPAuthenticationServer',
141-
'Get-NSlicenseExpiration',
141+
'Get-NSLicenseExpiration',
142142
'Get-NSMode',
143143
'Get-NSNTPServer',
144144
'Get-NSResponderAction',

NetScaler/Public/Get-NSCurrentTime.ps1

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Get-NSCurrentTime {
1919
Retrieve the current NetScaler Time and returns as date object
2020
.DESCRIPTION
2121
Retrieve the current NetScaler Time and returns as date object
22-
.PARAMETER NSSession
22+
.PARAMETER Session
2323
An existing custom NetScaler Web Request Session object returned by Connect-NSAppliance
2424
.EXAMPLE
2525
Get-NSCurrentTime -Session $Session
@@ -29,22 +29,19 @@ function Get-NSCurrentTime {
2929
#>
3030
[CmdletBinding()]
3131
param (
32-
[Parameter(Mandatory=$true)] [PSObject]$Session
32+
$Session = $Script:Session
3333
)
3434

3535
begin {
3636
_AssertSessionActive
3737
}
38-
38+
3939
process {
4040
$response = _InvokeNSRestApi -Session $Session -Method GET -Type nsconfig
4141
$currentdatestr = $response.nsconfig.systemtime
4242
Write-Verbose "systemtime: $currentdatestr"
43-
$date = get-date "1/1/1970"
43+
$date = Get-Date -Date '1/1/1970'
4444
$nsdate = $date.AddSeconds($currentdatestr)
45+
$nsdate
4546
}
46-
47-
end{
48-
return $nsdate
49-
}
50-
}
47+
}

NetScaler/Public/Get-NSLicenseExpiration.ps1

Lines changed: 76 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -14,102 +14,88 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
#>
1616

17-
function Get-NSlicenseExpiration {
18-
<#
19-
.SYNOPSIS
20-
Grabs Netscaler license expiration information via REST
21-
.DESCRIPTION
22-
Grabs Netscaler license expiration information via REST.
23-
.PARAMETER NSSession
24-
An existing custom NetScaler Web Request Session object returned by Connect-NSAppliance
25-
.EXAMPLE
26-
Get-NSlicenseExpiration -Session $Session
27-
.NOTES
28-
Author: Ryan Butler - @ryan_c_butler
29-
Date Created: 09-07-2017
30-
#>
31-
[CmdletBinding()]
32-
param (
33-
[Parameter(Mandatory=$true)] [PSObject]$Session
34-
)
35-
36-
begin{
37-
_AssertSessionActive
38-
#Grabs current time from Netscaler
39-
$currentnstime = Get-NSCurrentTime -Session $Session
40-
$results = @()
41-
}
17+
function Get-NSLicenseExpiration {
18+
<#
19+
.SYNOPSIS
20+
Grabs Netscaler license expiration information via REST
21+
.DESCRIPTION
22+
Grabs Netscaler license expiration information via REST.
23+
.PARAMETER Session
24+
An existing custom NetScaler Web Request Session object returned by Connect-NSAppliance
25+
.EXAMPLE
26+
Get-NSlicenseExpiration -Session $Session
27+
.NOTES
28+
Author: Ryan Butler - @ryan_c_butler
29+
Date Created: 09-07-2017
30+
#>
31+
[CmdletBinding()]
32+
param (
33+
$Session = $Script:Session
34+
)
4235

43-
process {
44-
45-
try {
46-
$lics = Get-NSSystemFile -Session $Session -filelocation "/nsconfig/license"|Where-Object {$_.filename -like "*.lic"}
36+
begin{
37+
_AssertSessionActive
38+
# Grabs current time from Netscaler
39+
$currentnstime = Get-NSCurrentTime -Session $Session
40+
$results = @()
4741
}
48-
Catch{
49-
throw "Error reading license(s)"
50-
}
51-
52-
foreach ($lic in $lics)
53-
{
54-
Write-verbose "Reading $($lic.filename)"
55-
56-
#Converts returned value from BASE64 to UTF8
57-
$lic = Get-NSSystemFile -Session $Session -filelocation "/nsconfig/license" -filename $lic.filename
58-
$info = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($lic.filecontent))
59-
60-
#Grabs needed line that has licensing information
61-
$lines = $info.Split("`n")|where-object{$_ -like "*INCREMENT*"}
62-
63-
#Parses needed date values from string
64-
$licdates = @()
65-
foreach ($line in $lines)
66-
{
67-
$licdate = $line.Split()
68-
69-
if ($licdate[4] -like "permanent")
70-
{
71-
$expire = "PERMANENT"
72-
}
73-
else
74-
{
75-
$expire = [datetime]$licdate[4]
76-
}
77-
78-
#adds date to object
79-
$temp = New-Object PSObject -Property @{
80-
expdate = $expire
81-
feature = $licdate[1]
82-
}
83-
$licdates += $temp
42+
43+
process {
44+
try {
45+
$lics = Get-NSSystemFile -Session $Session -Filelocation '/nsconfig/license' | Where-Object {$_.filename -like '*.lic'}
46+
} catch{
47+
throw 'Error reading license(s)'
8448
}
85-
86-
foreach ($date in $licdates)
87-
{
88-
if ($date.expdate -like "PERMANENT")
89-
{
90-
$expires = "PERMANENT"
91-
$span = "9999"
92-
}
93-
else
94-
{
95-
$expires = ($date.expdate).ToShortDateString()
96-
$span = (New-TimeSpan -Start $currentnstime -end ($date.expdate)).days
49+
50+
foreach ($lic in $lics) {
51+
Write-verbose "Reading [$($lic.filename)]"
52+
53+
# Converts returned value from BASE64 to UTF8
54+
$lic = Get-NSSystemFile -Session $Session -Filelocation '/nsconfig/license' -Filename $lic.filename
55+
$info = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($lic.filecontent))
56+
57+
# Grabs needed line that has licensing information
58+
$lines = $info.Split("`n") | Where-Object {$_ -like '*INCREMENT*'}
59+
60+
# Parses needed date values from string
61+
$licdates = @()
62+
foreach ($line in $lines) {
63+
$licdate = $line.Split()
64+
65+
if ($licdate[4] -like 'permanent') {
66+
$expire = 'PERMANENT'
67+
} else {
68+
$expire = [datetime]$licdate[4]
69+
}
70+
71+
# Adds date to object
72+
$temp = [pscustomobject]@{
73+
expdate = $expire
74+
feature = $licdate[1]
75+
}
76+
$licdates += $temp
9777
}
98-
99-
$temp = New-Object PSObject -Property @{
100-
Expires = $expires
101-
Feature = $date.feature
102-
DaysLeft = $span
103-
LicenseFile = $lic.filename
78+
79+
foreach ($date in $licdates) {
80+
if ($date.expdate -like 'PERMANENT') {
81+
$expires = 'PERMANENT'
82+
$span = '9999'
83+
} else {
84+
$expires = ($date.expdate).ToShortDateString()
85+
$span = (New-TimeSpan -Start $currentnstime -End $date.expdate).Days
10486
}
105-
$results += $temp
106-
}
107-
108-
}
109-
}
11087

111-
end{
112-
return $results
88+
$temp = [pscustomobject]@{
89+
Expires = $expires
90+
Feature = $date.feature
91+
DaysLeft = $span
92+
LicenseFile = $lic.filename
93+
}
94+
$results += $temp
95+
}
96+
}
97+
98+
$results
11399
}
114100
}
115101

NetScaler/Public/Update-NSAppliance.ps1

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ limitations under the License.
1717
function Update-NSAppliance {
1818
<#
1919
.SYNOPSIS
20-
Grabs Netscaler license expiration information via REST
20+
Updates a Netscaler and uses firmware from a remote location.
2121
.DESCRIPTION
22-
Grabs Netscaler license expiration information via REST.
23-
.PARAMETER NSSession
22+
Updates a Netscaler and uses firmware from a remote location.
23+
.PARAMETER Session
2424
An existing custom NetScaler Web Request Session object returned by Connect-NSAppliance
25-
.PARAMETER url
25+
.PARAMETER Url
2626
URL for Netscaler firmware (MANDATORY)
27-
.PARAMETER noreboot
27+
.PARAMETER NoReboot
2828
Don't reboot after upgrade
29-
.PARAMETER nocallhome
29+
.PARAMETER NoCallhome
3030
Don't enable CallHome
3131
.EXAMPLE
3232
Update-NSAppliance -Session $Session -url "https://mywebserver/build-11.1-47.14_nc.tgz"
@@ -37,56 +37,49 @@ function Update-NSAppliance {
3737
#>
3838
[CmdletBinding()]
3939
param (
40-
[Parameter(Mandatory=$true)] [PSObject]$Session,
41-
[Parameter(Mandatory=$true)] $url,
42-
[switch]$noreboot,
43-
[switch]$nocallhome
40+
[Parameter(Mandatory = $true)]
41+
[string]$Url,
42+
43+
$Session = $Script:Session,
44+
45+
[switch]$NoReboot,
46+
47+
[switch]$NoCallhome
4448
)
4549

46-
begin{
50+
begin {
4751
_AssertSessionActive
4852
}
4953

5054
process {
51-
52-
if(!$nocallhome)
53-
{
54-
write-verbose "Enabling callhome"
55-
$ch = $true
56-
}
57-
else
58-
{
59-
write-verbose"Disabling callhome"
55+
if (-not $nocallhome) {
56+
Write-Verbose -Message 'Enabling callhome'
57+
$ch = $true
58+
} else {
59+
Write-Verbose -Message 'Disabling callhome'
6060
$ch = $false
6161
}
6262

63-
if(!$noreboot)
64-
{
65-
Write-Verbose "Rebooting NS Appliance"
63+
if (-not $NoReboot) {
64+
Write-Verbose -Message 'Rebooting NS Appliance'
6665
$reboot = $true
67-
}
68-
else
69-
{
70-
Write-Verbose "Skipping reboot"
66+
} else {
67+
Write-Verbose -Message 'Skipping reboot'
7168
$reboot = $false
7269
}
7370

74-
#Build upgrade payload
71+
# Build upgrade payload
7572
$payload = @{
76-
"url" = $url;
77-
"y" = $reboot;
78-
"l" = $ch;
79-
}
80-
81-
#Attempt upgrade
82-
try{
83-
_InvokeNSRestApi -Session $Session -Method POST -Type install -Payload $payload
73+
'url' = $Url
74+
'y' = $reboot
75+
'l' = $ch
8476
}
85-
Catch{
77+
78+
# Attempt upgrade
79+
try {
80+
_InvokeNSRestApi -Session $Session -Method POST -Type install -Payload $payload
81+
} catch{
8682
throw $_
8783
}
88-
89-
9084
}
91-
92-
}
85+
}

0 commit comments

Comments
 (0)