-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathns-get-file-with-posh-ssh.ps1
31 lines (24 loc) · 1.05 KB
/
ns-get-file-with-posh-ssh.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Install-Module -Name Posh-SSH
$NetscalerIP = '10.00.00.1'
$SSHSession = New-SSHSession -ComputerName $NetscalerIP
$ShellCommand = 'shell cat /var/log/nsvpn.log'
$Output = Invoke-SSHCommand -Index $($SSHSession.SessionId) -Command $ShellCommand
$Output.Output | out-file c:\windows\temp\nsvpn.log.txt -Force
start c:\windows\temp\nsvpn.log.txt
$ShellCommand = 'shell cat /flash/nsconfig/ns.conf'
$Output = Invoke-SSHCommand -Index $($SSHSession.SessionId) -Command $ShellCommand
$Output.Output | out-file c:\windows\temp\ns.conf.txt -Force
start c:\windows\temp\ns.conf.txt
$ShellCommand = 'shell cat /var/log/ns.log'
$Output = Invoke-SSHCommand -Index $($SSHSession.SessionId) -Command $ShellCommand
$Output.Output | out-file c:\windows\temp\ns.log.txt -Force
start c:\windows\temp\ns.log.txt
write-verbose -Message "Get-SSHSession" -Verbose
Get-SSHSession
Start-Sleep 3
write-verbose -Message "Remove-SSHSession" -Verbose
Remove-SSHSession -SessionId $($SSHSession.SessionId)
Start-Sleep 3
write-verbose -Message "Get-SSHSession" -Verbose
Get-SSHSession
Start-Sleep 3