-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-DCNMSwitch.ps1
More file actions
33 lines (33 loc) · 1.16 KB
/
Get-DCNMSwitch.ps1
File metadata and controls
33 lines (33 loc) · 1.16 KB
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
function Get-DCNMSwitch {
<#
.SYNOPSIS
Retrieve list of switches within a fabric
.DESCRIPTION
This cmdlet will invoke a REST get against the DCNM API Control - Inventory path
.EXAMPLE
Get-DCNMObject
.EXAMPLE
Get-DCNMObject -name TST
.PARAMETER name
Name of a fabric
/#>
param
(
[Parameter(Mandatory=$false)]
[string]$SwitchName="*",
[Parameter(Mandatory=$false)]
[ValidateSet("Spine","Leaf","Border","Border Spine","Border Gateway","Border Gateway Spine","Super Spine","Border Super Spine","Border Gateway Super Spine","Access","Aggregation","Edge Router","Core Router","ToR","*")]
[string]$SwitchRole="*",
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string]$fabricName
)
Begin {}
Process {
$uri = "$Global:DCNMHost/rest/control/fabrics/$FabricName/inventory"
$response = Get-DCNMObject -uri $uri
$response | Where-Object {($_.hostName -like $SwitchName -and $_.switchRole -like $SwitchRole.ToLower())}
}
End {
if ($response) {New-Variable -Scope Global -Name DCNMSwitch_$fabricName -Value $response -Force}
}
}