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

Commit

Permalink
Version 2.0 - Core functions complete (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
BornToBeRoot committed Sep 15, 2016
1 parent 1c203c9 commit 370707f
Show file tree
Hide file tree
Showing 32 changed files with 1,315 additions and 1,850 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_Credentials.xml
Documentation/Function/Images/Thumbs.db
3 changes: 0 additions & 3 deletions Documentation/Add-BrocadeVLAN.README.md

This file was deleted.

3 changes: 0 additions & 3 deletions Documentation/Brocade-CopyConfigToTFTP.README.md

This file was deleted.

44 changes: 44 additions & 0 deletions Documentation/Function/Get-ICXSession.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Get-ICXSession

Get a Brocade ICX session.

* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Get-ICXSession.ps1)

## Description

Get one or multiple Brocade ICX sessions based on SessionID or ComputerName.

![Screenshot](Images/Get-ICXSession.png?raw=true)

## Syntax

```powershell
Get-ICXSession [<CommonParameters>]
Get-ICXSession [-SessionID] <Int32[]> [<CommonParameters>]
Get-ICXSession [-ComputerName] <String[]> [[-CaseSensitive]] [<CommonParameters>]
```

## Example 1

```powershell
PS> Get-ICXSession -SessionID 1,2
SessionID ComputerName Session Stream
--------- ------------ ------- ------
1 megatron SSH.SshSession Renci.SshNet.ShellStream
2 megatron SSH.SshSession Renci.SshNet.ShellStream
```

## Example 2

```powershell
PS> Get-ICXSession -ComputerName megatron
SessionID ComputerName Session Stream
--------- ------------ ------- ------
0 megatron SSH.SshSession Renci.SshNet.ShellStream
1 megatron SSH.SshSession Renci.SshNet.ShellStream
2 megatron SSH.SshSession Renci.SshNet.ShellStream
```
42 changes: 42 additions & 0 deletions Documentation/Function/Get-ICXVLAN.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Get-ICXVLAN

Get VLANs from a Brocade ICX Switch.

* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Functions/VLAN/Get-ICXVLAN.ps1)

## Description

Get VLANs from a Brocade ICX Switch as PSCustomObject, which can be further processed.

![Screenshot](Images/Get-ICXVLAN.png?raw=true)

## Syntax

```powershell
Get-ICXVLAN [-ComputerName] <String[]> [[-AcceptKey]] [[-Credential] <PSCredential>] [<CommonParameters>]
Get-ICXVLAN [-Session] <PSObject[]> [<CommonParameters>]
```

## Example 1

```powershell
PS> Get-ICXVLAN -ComputerName megatron
SessionID ComputerName ID Name By TaggedPort UntaggedPort
--------- ------------ -- ---- -- ---------- ------------
2 megatron 1001 Test1 port {0/1/1} {0/1/5, 0/1/6, 0/1/7, 0/1/8, ...}
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, ...}
```

## Example 2

```powershell
PS> $Session = Get-ICXSession -SessionID 0,2
PS> Get-ICXVLAN -Session $Session | Where-Object {$_.Name -eq "Test1"}
SessionID ComputerName ID Name By TaggedPort UntaggedPort
--------- ------------ -- ---- -- ---------- ------------
0 megatron 1001 Test1 port {0/1/1} {0/1/5, 0/1/6, 0/1/7, 0/1/8, ...}
2 megatron 1001 Test1 port {0/1/1} {0/1/5, 0/1/6, 0/1/7, 0/1/8, ...}
```
Binary file added Documentation/Function/Images/Get-ICXSession.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/Function/Images/Get-ICXVLAN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/Function/Images/New-ICXSession.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/Function/Images/Test-ICXSession.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/Function/Images/Thumbs.db
Binary file not shown.
54 changes: 54 additions & 0 deletions Documentation/Function/Invoke-ICXCommand.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Invoke-ICXCommand

Invoke an SSH command in a Brocade ICX session.

* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Invoke-ICXCommand.ps1)

## Description

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.

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.

![Screenshot](Images/Invoke-ICXCommand.png?raw=true)

## Syntax

```powershell
Invoke-ICXCommand [-Command] <String> [-Session] <PSObject[]> [[-Timeout] <Int32>] [[-EndString]
<String[]>] [<CommonParameters>]
Invoke-ICXCommand [-Command] <String> [-Session] <PSObject[]> [[-CompatibilityMode]] [[-Seconds]
<Int32>] [<CommonParameters>]
Invoke-ICXCommand [-Command] <String> [-Session] <PSObject[]> [[-CompatibilityMode]] [[-Milliseconds]
<Int32>] [<CommonParameters>]
```

## Example 1

```powershell
PS> Get-ICXSession | Invoke-ICXCommand -Command "sh clock"
SessionID ComputerName Output
--------- ------------ ------
0 megatron {14:53:53 GMT+01 Thu Aug 25 2016...
1 megaTRON {14:53:53 GMT+01 Thu Aug 25 2016...
2 megatron {14:53:53 GMT+01 Thu Aug 25 2016...
```

## Example 2

```powershell
PS> $Session = Get-ICXSession -SessionID 0
PS> (Invoke-ICXCommand -Command "sh clock" -Session $Session).Output
14:54:13 GMT+01 Thu Aug 25 2016
```

## Example 3
```powershell
PS> (Get-ICXSession -SessionID 2 | Invoke-ICXCommand -Command "copy running-config tftp 192.168.XXX.XXX" -CompatibilityMode -Seconds 5).Output
Upload running-config to TFTP server done.
```
27 changes: 27 additions & 0 deletions Documentation/Function/New-ICXSession.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# New-ICXSession

Create a new Brocade ICX sessions over SSH.

* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/New-ICXSession.ps1)

## Description

Create one or multiple Brocade ICX session over SSH. If no credentials are submitted, a credential popup will appear.

![Screenshot](Images/New-ICXSession.png?raw=true)

## Syntax

```powershell
New-ICXSession [-ComputerName] <String[]> [[-AcceptKey]] [[-Credential] <PSCredential>] [<CommonParameters>]
```

## Example

```powershell
PS> New-ICXSession -ComputerName megatron
SessionID ComputerName Session Stream
--------- ------------ ------- ------
0 megatron SSH.SshSession Renci.SshNet.ShellStream
```
38 changes: 38 additions & 0 deletions Documentation/Function/Remove-ICXSession.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Remove-ICXSession

Remove a Brocade ICX session.

* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Remove-ICXSession.ps1)

## Description

Remove one or multiple Brocade ICX sessions.

![Screenshot](Images/Remove-ICXSession.png?raw=true)

## Syntax

```powershell
Remove-ICXSession [-SessionID] <Int32[]> [<CommonParameters>]
Remove-ICXSession [-ComputerName] <String[]> [[-CaseSensitive]] [<CommonParameters>]
Remove-ICXSession [-Session] <PSObject[]> [<CommonParameters>]
```

## Example 1

```powershell
PS> Remove-ICXSession -SessionID 1
```

## Example 2

```powershell
PS> Get-ICXSession | Remove-ICXSession
```

## Example 3
```powershell
PS> Remove-ICXSession -ComputerName megatron
```
34 changes: 34 additions & 0 deletions Documentation/Function/Test-ICXSession.README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Test-ICXSession

Test if a session is a valid Brocade ICX session.

* [view function](https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Module/BrocadeICX/Core/Test-ICXSession.ps1)

## Description

Test if a session is a valid Brocade ICX session and managed by the BrocadeICX module.

![Screenshot](Images/Test-ICXSession.png?raw=true)

## Syntax

```powershell
Test-ICXSession [-Session] <PSObject> [<CommonParameters>]
```

## Example 1

```powershell
PS> $Session = Get-ICXSession -SessionID 0
PS> Test-ICXSession -Session $Session
true
```

## Example 2

```powershell
PS> "Test" | Test-ICXSessions
false
```
3 changes: 0 additions & 3 deletions Documentation/Get-BrocadeVLAN.README.md

This file was deleted.

Binary file added Module/BrocadeICX/BrocadeICX.psd1
Binary file not shown.
19 changes: 19 additions & 0 deletions Module/BrocadeICX/BrocadeICX.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
###############################################################################################################
# Language : PowerShell 4.0
# Filename : BrocadeICX.psm1
# Autor : BornToBeRoot (https://github.com/BornToBeRoot)
# Description : Module to administrate Brocade ICX Switches over SSH
# Repository : https://github.com/BornToBeRoot/PowerShell_BrocadeICX
###############################################################################################################

# Global array to store Brocade ICX sessions
if(-not(Test-Path Variable:BrocadeICXSessions))
{
[System.Collections.ArrayList]$Global:BrocadeICXSessions = @()
}

# Import core functions
Get-ChildItem -Path "$PSScriptRoot\Core" -Recurse | Where-Object {$_.Name.EndsWith(".ps1")} | ForEach-Object {. $_.FullName}

# Import additional functions
Get-ChildItem -Path "$PSScriptRoot\Functions" -Recurse | Where-Object {$_.Name.EndsWith(".ps1")} | ForEach-Object {. $_.FullName}
Loading

0 comments on commit 370707f

Please sign in to comment.