-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInvoke-DCNMCliCommand.ps1
41 lines (39 loc) · 1.45 KB
/
Invoke-DCNMCliCommand.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
function Invoke-DCNMCliCommand {
<#
.SYNOPSIS
Executes a command on switches
.DESCRIPTION
This cmdlet will invoke a REST POST against Config Deployer API using the exec_freeform template
.EXAMPLE
Get-DCNMSwitch -Fabric DC1 -SwitchRole Leaf | Invoke-DCNMCliCommand -ExecFreeform "show nve peers"
.PARAMETER serialNumber
Serial number of switch(es)
.PARAMETER ExecFreeform
Exec level command line
/#>
param
(
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string]$serialNumber,
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[string]$ExecFreeform,
[Parameter(Mandatory=$false, DontShow)]
[switch]$JSON
)
Begin {
$uri = "$Global:DCNMHost/rest/config/delivery/exec_freeform/exec"
$deviceList = @()
}
Process {
$deviceList += $serialNumber
}
End {
$cli = New-Object -TypeName psobject
$cli | Add-Member -Type NoteProperty -Name CLI -Value $ExecFreeform
$body = New-Object -TypeName psobject
$body | Add-Member -Type NoteProperty -Name deviceList -Value $deviceList
$body | Add-Member -Type NoteProperty -Name paramValueMap -Value $cli
if ($JSON) {$uri ; $Global:DCNM_JSON = (ConvertTo-Json -InputObject $body -Depth 10) ; $Global:DCNM_JSON} else {
$response = New-DCNMObject -uri $uri -object (ConvertTo-Json -InputObject $body -Depth 10) ; $response}
}
}