Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   README.md
	modified:   public/Devices.ps1
	modified:   public/Networks.ps1
	modified:   public/Organizations.ps1
	modified:   public/Products/Appliances.ps1
	modified:   public/Products/Switches.ps1

Added the ComfirmImpact = 'High' CmdLetBinding to all functions that require confirmation.
  • Loading branch information
Clifra-Jones committed Jun 18, 2024
1 parent 3d3620b commit 16525da
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 27 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,13 @@ Set-MerakiAPI -APIKey '{key string}' -OrgId 'XXXXXX' -SecureKey

This will create the file .meraki/config.json file in your user profile.

Create additional profiles.
Profiles are used to identify the Organization you wish to operate on. Profiles and the parameter -OrgId are only required on functions that operate at the organization level. For appliances, devices, etc. you do not need to provide a profile or use the -OrgId parameter.

When creating an additional profile DO NOT include the -APIKey parameter. You only need the -OrgId and the -ProfileName parameters.

```powershell
Set-MerakiAPI -OrgId '987456' -ProfileName "MyOtherOrg"
```

See the module reference for additional information on functions, syntax, and examples.
18 changes: 14 additions & 4 deletions public/Devices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ function Start-MerakiDeviceBlink() {
Set-Alias -Name StartMDevBlink -Value Start-MerakiDeviceBlink -Option ReadOnly

function Restart-MerakiDevice() {
[CmdLetBinding(DefaultParameterSetName = 'default')]
[CmdLetBinding(
DefaultParameterSetName = 'default',
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param(
[Parameter(
Mandatory = $true,
Expand All @@ -99,9 +103,12 @@ function Restart-MerakiDevice() {
$headers = Get-Headers

try {
$response = Invoke-RestMethod -Method POST -Uri $Uri -Headers $Headers -PreserveAuthorizationOnRedirect
$DeviceName = (Get-MerakiDevice -Serial $serial).Name
if ($PSCmdlet.ShouldProcess($DeviceName, "Restart")) {
$response = Invoke-RestMethod -Method POST -Uri $Uri -Headers $Headers -PreserveAuthorizationOnRedirect

return $response
return $response
}
} catch {
throw $_
}
Expand Down Expand Up @@ -322,7 +329,10 @@ function Set-MerakiDevice {
}

function Remove-MerakiNetworkDevice() {
[CmdletBinding(SupportsShouldProcess)]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param (
[Parameter(
Mandatory,
Expand Down
26 changes: 20 additions & 6 deletions public/Networks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ function Set-MerakiNetwork() {
}

function Remove-MerakiNetwork() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmIMpact = 'High'
)]
Param(
[Parameter(
Mandatory,
Expand Down Expand Up @@ -175,7 +179,10 @@ function Connect-MerakiNetworkToTemplate() {
}

function Disconnect-MerakiNetworkFromTemplate() {
[CmdletBinding(DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High')]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId,
Expand All @@ -185,13 +192,17 @@ function Disconnect-MerakiNetworkFromTemplate() {
$Header = Get-Headers

$Uri = "{0}/networks/{1}/unbind" -f $BaseURI, $NetworkId

if ($RetainConfigs.IsPresent) {
$body = @{"retainConfigs" = "true"} | ConvertTo-Json -Compress
}

try {
$response = Invoke-RestMethod -Method POST -Uri $Uri -Headers $Header -Body $body -PreserveAuthorizationOnRedirect
return $response
$NetworkName = (Get-MerakiNetwork -networkID $NetworkId).Name
If ($PSCmdlet.ShouldProcess($NetworkName, 'UnBind')) {
$response = Invoke-RestMethod -Method POST -Uri $Uri -Headers $Header -Body $body -PreserveAuthorizationOnRedirect
return $response
}
} catch {
throw $_
}
Expand All @@ -212,7 +223,10 @@ function Disconnect-MerakiNetworkFromTemplate() {


function Split-MerakiNetwork() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High')]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId
Expand All @@ -224,7 +238,7 @@ function Split-MerakiNetwork() {

$Network = Get-MerakiNetwork -networkID $NetworkId

if ($PSCmdlet.ShouldProcess('Split',"Network $($Network.NAme)")) {
if ($PSCmdlet.ShouldProcess("Network $($Network.Name)", "Split")) {
try {
$response = Invoke-RestMethod -Method POST -Uri $Uri -Headers $Header -PreserveAuthorizationOnRedirect
return $response
Expand Down
12 changes: 8 additions & 4 deletions public/Organizations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2196,9 +2196,9 @@ function Get-MerakiOrganizationApplianceVpnStats() {

$Uri = "{0}/organizations/{1}/appliance/vpn/stats" -f $BaseURI, $OrgID

$TimeSpan_Seconds = (New-TimeSpan -Days $timespan).TotalSeconds
$TimeSpan_Seconds = (New-TimeSpan -Days $TimeSpan).TotalSeconds

$Uri = "{0}?perPage={1}&networkIds%5B%5D={2}&timespan={3}" -f $Uri, $timespan, $id, $TimeSpan_Seconds
$Uri = "{0}?perPage={1}&networkIds%5B%5D={2}&timespan={3}" -f $Uri, $TimeSpan, $id, $TimeSpan_Seconds

try {
$response = Invoke-RestMethod -Method GET -Uri $Uri -Headers $Headers -PreserveAuthorizationOnRedirect
Expand Down Expand Up @@ -2240,7 +2240,7 @@ function Get-MerakiOrganizationApplianceVpnStats() {
The Network Id.
.PARAMETER perPage
The number of entries per page returned. Acceptable range is 3 - 300. Default is 300.
.PARAMETER timespan
.PARAMETER TimeSpan
Number of seconds to return data for. default = 5.
.PARAMETER Summarize
Summarize the statistics,
Expand All @@ -2257,7 +2257,11 @@ Set-Alias -Name GMOAVpnStats -Value Get-MerakiOrganizationApplianceVpnStats -Opt
set-Alias -Name Get-MerakiNetworkApplianceVpnStats -Value Get-MerakiOrganizationApplianceVpnStats

function Merge-MerakiOrganizationNetworks() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$Name,
Expand Down
33 changes: 26 additions & 7 deletions public/Products/Appliances.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,10 @@ function Add-MerakiApplianceCellularFirewallRule() {
}

function Remove-MerakiApplianceCellularFirewallRule() {
[CmdletBinding(SupportsShouldProcess)]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId,
Expand Down Expand Up @@ -2074,7 +2077,10 @@ function Set-MerakiApplianceInboundCellularFirewallRule() {
}

function Remove-MerakiApplianceInboundCellularFirewallRule() {
[CmdletBinding(SupportsShouldProcess)]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param (
[Parameter(Mandatory)]
[string]$NetworkId,
Expand Down Expand Up @@ -2380,7 +2386,10 @@ function Set-MerakiApplianceInboundFirewallRules() {
}

function Remove-MerakiApplianceInboundFirewallRule() {
[CmdletBinding(SupportsShouldProcess)]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param (
[Parameter(Mandatory)]
[string]$NetworkId,
Expand Down Expand Up @@ -2795,7 +2804,11 @@ function Set-MerakiApplianceL3FirewallRule() {
}

function Remove-MerakiApplianceL3FirewallRule() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(
Mandatory
Expand Down Expand Up @@ -3612,7 +3625,10 @@ Function Set-MerakiApplianceFirewallNatRule() {
}

function Remove-MerakiApplianceFirewallNatRule {
[CmdletBinding(SupportsShouldProcess)]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param (
[Parameter(Mandatory)]
[string]$NetworkId,
Expand Down Expand Up @@ -3866,7 +3882,10 @@ function Set-MerakiApplianceDelegatedStaticPrefix() {
}

function Remove-MerakiApplianceDelegatedStaticPrefix() {
[CmdletBinding(SupportsShouldProcess)]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'High'
)]
Param (
[Parameter(Mandatory)]
[string]$NetworkId,
Expand Down Expand Up @@ -4444,7 +4463,7 @@ function Get-MerakiApplianceWarmSpare() {
#>
}

function Set0MerakiApplianceWarmSpare() {
function Set-MerakiApplianceWarmSpare() {
[CmdletBinding(DefaultParameterSetName = 'default')]
Param(
[Parameter(
Expand Down
35 changes: 29 additions & 6 deletions public/Products/Switches.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ function Add-MerakiSwitchStackRoutingInterface() {
Set-Alias -Name AddMSSRteInt -Value Add-MerakiSwitchStackRoutingInterface

Function Remove-MerakiSwitchStackRoutingInterface() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'defailt')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId,
Expand Down Expand Up @@ -447,7 +451,11 @@ Set-Alias -Name SetMNSSRteStRoute -Value Set-MerakiSwitchStackRoutingStaticRoute
set-Alias -Name Set-MerakiNetworkSwitchStackRoutingStaticRoute -Value Set-MerakiSwitchStackRoutingStaticRoute -Option ReadOnly

function Remove-MerakiSwitchStackRoutingStaticRoute() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId,
Expand Down Expand Up @@ -965,7 +973,11 @@ function Set-MerakiSwitchRoutingInterface() {
Set-Alias -Name SetMSRteInt -Value Set-MerakiSwitchRoutingInterface

function Remove-MerakiSwitchRoutingInterface() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$Serial,
Expand Down Expand Up @@ -1343,7 +1355,11 @@ function Set-MerakiSwitchRoutingStaticRoute() {
}

function Remove-MerakiSwitchStaticRoute() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$Serial,
Expand Down Expand Up @@ -1540,7 +1556,11 @@ function Set-MerakiSwitchLAG() {
Set-Alias -Name Set-MerakiNetworkSwitchLAG -Value Set-MerakiSwitchLAG -Option ReadOnly

function Remove-MerakiSwitchLAG() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High'
)]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId,
Expand Down Expand Up @@ -2652,7 +2672,10 @@ function Set-MerakiSwitchQosRule() {
}

function Remove-MerakiSwitchQosRule() {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'default')]
[CmdletBinding(
SupportsShouldProcess,
DefaultParameterSetName = 'default',
ConfirmImpact = 'High')]
Param(
[Parameter(Mandatory = $true)]
[string]$NetworkId,
Expand Down

0 comments on commit 16525da

Please sign in to comment.