This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Test-ICXSession.ps1
68 lines (53 loc) · 1.79 KB
/
Test-ICXSession.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
###############################################################################################################
# Language : PowerShell 4.0
# Filename : Test-ICXSession.ps1
# Autor : BornToBeRoot (https://github.com/BornToBeRoot)
# Description : Test if a session is a valid Brocade ICX session
# Repository : https://github.com/BornToBeRoot/PowerShell_BrocadeICX
###############################################################################################################
<#
.SYNOPSIS
Test if a session is a valid Brocade ICX session
.DESCRIPTION
Test if a session is a valid Brocade ICX session and managed by the BrocadeICX module.
.EXAMPLE
$Session = Get-ICXSession -SessionID 0
Test-ICXSession -Session $Session
true
.EXAMPLE
"Test" | Test-ICXSessions
false
.LINK
https://github.com/BornToBeRoot/PowerShell_BrocadeICX/blob/master/Documentation/Function/Test-ICXSession.README.md
#>
function Test-ICXSession
{
[CmdletBinding()]
[OutputType('System.Boolean')]
param(
[Parameter(
Position=0,
ValueFromPipeline=$true,
Mandatory=$true,
HelpMessage='Brocade ICX session')]
[pscustomobject]$Session
)
Begin{
}
Process{
Write-Verbose -Message "Check if session is a valid Brocade ICX session..."
# Go through each Brocade ICX session
foreach($ICXSession in $Global:BrocadeICXSessions)
{
if($ICXSession -eq $Session)
{
Write-Verbose -Message "Valid Brocade ICX session found!"
return $true
}
}
Write-Verbose -Message "No valid Brocade ICX session found!"
return $false
}
End{
}
}