Skip to content
This repository was archived by the owner on Sep 5, 2020. It is now read-only.

Commit 370707f

Browse files
authored
Version 2.0 - Core functions complete (#2)
1 parent 1c203c9 commit 370707f

32 files changed

+1315
-1850
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
_Credentials.xml
1+
Documentation/Function/Images/Thumbs.db

Documentation/Add-BrocadeVLAN.README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

Documentation/Brocade-CopyConfigToTFTP.README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Get-ICXSession
2+
3+
Get a Brocade ICX session.
4+
5+
* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Get-ICXSession.ps1)
6+
7+
## Description
8+
9+
Get one or multiple Brocade ICX sessions based on SessionID or ComputerName.
10+
11+
![Screenshot](Images/Get-ICXSession.png?raw=true)
12+
13+
## Syntax
14+
15+
```powershell
16+
Get-ICXSession [<CommonParameters>]
17+
18+
Get-ICXSession [-SessionID] <Int32[]> [<CommonParameters>]
19+
20+
Get-ICXSession [-ComputerName] <String[]> [[-CaseSensitive]] [<CommonParameters>]
21+
```
22+
23+
## Example 1
24+
25+
```powershell
26+
PS> Get-ICXSession -SessionID 1,2
27+
28+
SessionID ComputerName Session Stream
29+
--------- ------------ ------- ------
30+
1 megatron SSH.SshSession Renci.SshNet.ShellStream
31+
2 megatron SSH.SshSession Renci.SshNet.ShellStream
32+
```
33+
34+
## Example 2
35+
36+
```powershell
37+
PS> Get-ICXSession -ComputerName megatron
38+
39+
SessionID ComputerName Session Stream
40+
--------- ------------ ------- ------
41+
0 megatron SSH.SshSession Renci.SshNet.ShellStream
42+
1 megatron SSH.SshSession Renci.SshNet.ShellStream
43+
2 megatron SSH.SshSession Renci.SshNet.ShellStream
44+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Get-ICXVLAN
2+
3+
Get VLANs from a Brocade ICX Switch.
4+
5+
* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Functions/VLAN/Get-ICXVLAN.ps1)
6+
7+
## Description
8+
9+
Get VLANs from a Brocade ICX Switch as PSCustomObject, which can be further processed.
10+
11+
![Screenshot](Images/Get-ICXVLAN.png?raw=true)
12+
13+
## Syntax
14+
15+
```powershell
16+
Get-ICXVLAN [-ComputerName] <String[]> [[-AcceptKey]] [[-Credential] <PSCredential>] [<CommonParameters>]
17+
18+
Get-ICXVLAN [-Session] <PSObject[]> [<CommonParameters>]
19+
```
20+
21+
## Example 1
22+
23+
```powershell
24+
PS> Get-ICXVLAN -ComputerName megatron
25+
26+
SessionID ComputerName ID Name By TaggedPort UntaggedPort
27+
--------- ------------ -- ---- -- ---------- ------------
28+
2 megatron 1001 Test1 port {0/1/1} {0/1/5, 0/1/6, 0/1/7, 0/1/8, ...}
29+
2 megatron 1002 Test2 port {0/1/1, 0/1/2, 0/1/3, 0/1/4} {0/1/11, 0/1/12, 0/1/13, 0/1/14, ...}
30+
```
31+
32+
## Example 2
33+
34+
```powershell
35+
PS> $Session = Get-ICXSession -SessionID 0,2
36+
PS> Get-ICXVLAN -Session $Session | Where-Object {$_.Name -eq "Test1"}
37+
38+
SessionID ComputerName ID Name By TaggedPort UntaggedPort
39+
--------- ------------ -- ---- -- ---------- ------------
40+
0 megatron 1001 Test1 port {0/1/1} {0/1/5, 0/1/6, 0/1/7, 0/1/8, ...}
41+
2 megatron 1001 Test1 port {0/1/1} {0/1/5, 0/1/6, 0/1/7, 0/1/8, ...}
42+
```
22.2 KB
Loading
10.9 KB
Loading
Loading
21.1 KB
Loading
Loading
Loading
33 KB
Binary file not shown.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Invoke-ICXCommand
2+
3+
Invoke an SSH command in a Brocade ICX session.
4+
5+
* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Invoke-ICXCommand.ps1)
6+
7+
## Description
8+
9+
Invoke an SSH command into one or multiple Brocade ICX session(s). By default, the function will try to detect the SSH output automatically based on the first and last string. Normally the output starts with the SSH command (which was passed) and ends with SSH@HOSTNAME#. If the automatic detection fails and the timeout is reached, the output which is currently in the SSH stream will be returned.
10+
11+
If you have trouble with some commands (such as `copy running-config tftp ...`), you should try the compatibility mode (`-CompatibilityMode`) and define your own timout values (`-Seconds` or `-Milliseconds`). With the compatibility mode, the SSH command ist executed and the output of the SSH stream is returned after a specific time.
12+
13+
![Screenshot](Images/Invoke-ICXCommand.png?raw=true)
14+
15+
## Syntax
16+
17+
```powershell
18+
Invoke-ICXCommand [-Command] <String> [-Session] <PSObject[]> [[-Timeout] <Int32>] [[-EndString]
19+
<String[]>] [<CommonParameters>]
20+
21+
Invoke-ICXCommand [-Command] <String> [-Session] <PSObject[]> [[-CompatibilityMode]] [[-Seconds]
22+
<Int32>] [<CommonParameters>]
23+
24+
Invoke-ICXCommand [-Command] <String> [-Session] <PSObject[]> [[-CompatibilityMode]] [[-Milliseconds]
25+
<Int32>] [<CommonParameters>]
26+
```
27+
28+
## Example 1
29+
30+
```powershell
31+
PS> Get-ICXSession | Invoke-ICXCommand -Command "sh clock"
32+
33+
SessionID ComputerName Output
34+
--------- ------------ ------
35+
0 megatron {14:53:53 GMT+01 Thu Aug 25 2016...
36+
1 megaTRON {14:53:53 GMT+01 Thu Aug 25 2016...
37+
2 megatron {14:53:53 GMT+01 Thu Aug 25 2016...
38+
```
39+
40+
## Example 2
41+
42+
```powershell
43+
PS> $Session = Get-ICXSession -SessionID 0
44+
PS> (Invoke-ICXCommand -Command "sh clock" -Session $Session).Output
45+
46+
14:54:13 GMT+01 Thu Aug 25 2016
47+
```
48+
49+
## Example 3
50+
```powershell
51+
PS> (Get-ICXSession -SessionID 2 | Invoke-ICXCommand -Command "copy running-config tftp 192.168.XXX.XXX" -CompatibilityMode -Seconds 5).Output
52+
53+
Upload running-config to TFTP server done.
54+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# New-ICXSession
2+
3+
Create a new Brocade ICX sessions over SSH.
4+
5+
* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/New-ICXSession.ps1)
6+
7+
## Description
8+
9+
Create one or multiple Brocade ICX session over SSH. If no credentials are submitted, a credential popup will appear.
10+
11+
![Screenshot](Images/New-ICXSession.png?raw=true)
12+
13+
## Syntax
14+
15+
```powershell
16+
New-ICXSession [-ComputerName] <String[]> [[-AcceptKey]] [[-Credential] <PSCredential>] [<CommonParameters>]
17+
```
18+
19+
## Example
20+
21+
```powershell
22+
PS> New-ICXSession -ComputerName megatron
23+
24+
SessionID ComputerName Session Stream
25+
--------- ------------ ------- ------
26+
0 megatron SSH.SshSession Renci.SshNet.ShellStream
27+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Remove-ICXSession
2+
3+
Remove a Brocade ICX session.
4+
5+
* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Remove-ICXSession.ps1)
6+
7+
## Description
8+
9+
Remove one or multiple Brocade ICX sessions.
10+
11+
![Screenshot](Images/Remove-ICXSession.png?raw=true)
12+
13+
## Syntax
14+
15+
```powershell
16+
Remove-ICXSession [-SessionID] <Int32[]> [<CommonParameters>]
17+
18+
Remove-ICXSession [-ComputerName] <String[]> [[-CaseSensitive]] [<CommonParameters>]
19+
20+
Remove-ICXSession [-Session] <PSObject[]> [<CommonParameters>]
21+
```
22+
23+
## Example 1
24+
25+
```powershell
26+
PS> Remove-ICXSession -SessionID 1
27+
```
28+
29+
## Example 2
30+
31+
```powershell
32+
PS> Get-ICXSession | Remove-ICXSession
33+
```
34+
35+
## Example 3
36+
```powershell
37+
PS> Remove-ICXSession -ComputerName megatron
38+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test-ICXSession
2+
3+
Test if a session is a valid Brocade ICX session.
4+
5+
* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Test-ICXSession.ps1)
6+
7+
## Description
8+
9+
Test if a session is a valid Brocade ICX session and managed by the BrocadeICX module.
10+
11+
![Screenshot](Images/Test-ICXSession.png?raw=true)
12+
13+
## Syntax
14+
15+
```powershell
16+
Test-ICXSession [-Session] <PSObject> [<CommonParameters>]
17+
```
18+
19+
## Example 1
20+
21+
```powershell
22+
PS> $Session = Get-ICXSession -SessionID 0
23+
PS> Test-ICXSession -Session $Session
24+
25+
true
26+
```
27+
28+
## Example 2
29+
30+
```powershell
31+
PS> "Test" | Test-ICXSessions
32+
33+
false
34+
```

Documentation/Get-BrocadeVLAN.README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

Module/BrocadeICX/BrocadeICX.psd1

6.49 KB
Binary file not shown.

Module/BrocadeICX/BrocadeICX.psm1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###############################################################################################################
2+
# Language : PowerShell 4.0
3+
# Filename : BrocadeICX.psm1
4+
# Autor : BornToBeRoot (https://github.com/BornToBeRoot)
5+
# Description : Module to administrate Brocade ICX Switches over SSH
6+
# Repository : https://github.com/BornToBeRoot/PowerShell_BrocadeICX
7+
###############################################################################################################
8+
9+
# Global array to store Brocade ICX sessions
10+
if(-not(Test-Path Variable:BrocadeICXSessions))
11+
{
12+
[System.Collections.ArrayList]$Global:BrocadeICXSessions = @()
13+
}
14+
15+
# Import core functions
16+
Get-ChildItem -Path "$PSScriptRoot\Core" -Recurse | Where-Object {$_.Name.EndsWith(".ps1")} | ForEach-Object {. $_.FullName}
17+
18+
# Import additional functions
19+
Get-ChildItem -Path "$PSScriptRoot\Functions" -Recurse | Where-Object {$_.Name.EndsWith(".ps1")} | ForEach-Object {. $_.FullName}

0 commit comments

Comments
 (0)