Skip to content

Commit 7e92d5e

Browse files
author
Ryan Butler
committed
added update-nsappliance function
1 parent bfe2866 commit 7e92d5e

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

NetScaler/NetScaler.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ FunctionsToExport = @(
211211
'Set-NSResponderAction',
212212
'Set-NSSSLProfile',
213213
'Set-NSTimeZone',
214-
'Set-NSVPNVirtualServerTheme'
214+
'Set-NSVPNVirtualServerTheme',
215+
'Update-NSAppliance'
215216
)
216217

217218
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<#
2+
Copyright 2017 Ryan Butler
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 Update-NSAppliance {
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+
.PARAMETER url
26+
URL for Netscaler firmware (MANDATORY)
27+
.PARAMETER noreboot
28+
Don't reboot after upgrade
29+
.PARAMETER nocallhome
30+
Don't enable CallHome
31+
.EXAMPLE
32+
Update-NSAppliance -Session $Session -url "https://mywebserver/build-11.1-47.14_nc.tgz"
33+
.NOTES
34+
Author: Ryan Butler - @ryan_c_butler
35+
Date Created: 09-07-2017
36+
Will probably fail with VPX Express due to API timeout
37+
#>
38+
[CmdletBinding()]
39+
param (
40+
[Parameter(Mandatory=$true)] [PSObject]$Session,
41+
[Parameter(Mandatory=$true)] $url,
42+
[switch]$noreboot,
43+
[switch]$nocallhome
44+
)
45+
46+
begin{
47+
_AssertSessionActive
48+
}
49+
50+
process {
51+
52+
if(!$nocallhome)
53+
{
54+
write-verbose "Enabling callhome"
55+
$ch = $true
56+
}
57+
else
58+
{
59+
write-verbose"Disabling callhome"
60+
$ch = $false
61+
}
62+
63+
if(!$noreboot)
64+
{
65+
Write-Verbose "Rebooting NS Appliance"
66+
$reboot = $true
67+
}
68+
else
69+
{
70+
Write-Verbose "Skipping reboot"
71+
$reboot = $false
72+
}
73+
74+
#Build upgrade payload
75+
$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
84+
}
85+
Catch{
86+
throw $_
87+
}
88+
89+
90+
}
91+
92+
}

0 commit comments

Comments
 (0)