Public/Set-MerakiNetworkSwitchStackRoutingStaticRoute.ps1

function Set-MerakiNetworkSwitchStackRoutingStaticRoute {
    <#
    .SYNOPSIS
    Updates a network switch stack routing static route.
     
    .DESCRIPTION
    The Set-MerakiNetworkSwitchStackRoutingStaticRoute function allows you to update a network switch stack routing static route by providing the authentication token, network ID, switch stack ID, static route ID, and a JSON formatted string of the static route configuration.
     
    .PARAMETER AuthToken
    The authentication token (API key) required to access the Meraki Dashboard API.
     
    .PARAMETER NetworkId
    The ID of the network.
     
    .PARAMETER SwitchStackId
    The ID of the switch stack.
     
    .PARAMETER StaticRouteId
    The ID of the static route.
     
    .PARAMETER StaticRoute
    A JSON formatted string of the static route configuration.
     
    .EXAMPLE
    $StaticRouteConfig = [PSCustomObject]@{
        name = "My route"
        subnet = "192.168.1.0/24"
        nextHopIp = "1.2.3.4"
        advertiseViaOspfEnabled = $false
        preferOverOspfRoutesEnabled = $false
    }
 
    $StaticRoute = $StaticRouteConfig | ConvertTo-Json -Compress
    Set-MerakiNetworkSwitchStackRoutingStaticRoute -AuthToken "your-api-token" -NetworkId "1234" -SwitchStackId "5678" -StaticRouteId "91011" -StaticRoute $StaticRoute
 
    This example updates a network switch stack routing static route with the specified configuration.
     
    .NOTES
    The function requires the "Invoke-RestMethod" cmdlet to be available.
     
    The function returns the response from the API if the update is successful, otherwise, it displays an error message.
    #>

    
        [CmdletBinding()]
        param (
            [parameter(Mandatory=$true)]
            [string]$AuthToken,
            [parameter(Mandatory=$true)]
            [string]$NetworkId,
            [parameter(Mandatory=$true)]
            [string]$SwitchStackId,
            [parameter(Mandatory=$true)]
            [string]$StaticRouteId,
            [parameter(Mandatory=$true)]
            [string]$StaticRoute
        )
    
        try {
            $header = @{
                "X-Cisco-Meraki-API-Key" = $AuthToken
                "content-type" = "application/json; charset=utf-8"
            }
    
            $url = "https://api.meraki.com/api/v1/networks/$NetworkId/switch/stacks/$SwitchStackId/routing/staticRoutes/$StaticRouteId"
    
            $body = $StaticRoute
    
            $response = Invoke-RestMethod -Method Put -Uri $url -Header $header -UserAgent "MerakiPowerShellModule/1.0.2 DocNougat" -Body $body
            return $response
        }
        catch {
        Write-Debug $_
        Throw $_
    }
    }