Public/Invoke-MerakiNetworkWirelessAssignEthernetPortsProfile.ps1

function Invoke-MerakiNetworkWirelessAssignEthernetPortsProfile {
    <#
    .SYNOPSIS
    Assigns a network wireless Ethernet ports profile.
     
    .DESCRIPTION
    The Invoke-MerakiNetworkWirelessAssignEthernetPortsProfile function allows you to assign a network wireless Ethernet ports profile by providing the authentication token, network ID, and a JSON formatted string of the profile assignment configuration.
     
    .PARAMETER AuthToken
    The authentication token (API key) required to access the Meraki Dashboard API.
     
    .PARAMETER NetworkId
    The ID of the network.
     
    .PARAMETER ProfileAssignment
    A JSON formatted string of the profile assignment configuration.
     
    .EXAMPLE
    $ProfileAssignment = [PSCustomObject]@{
        serials = @(
            "Q234-ABCD-0001",
            "Q234-ABCD-0002",
            "Q234-ABCD-0003"
        )
        profileId = "1001"
    }
 
    $ProfileAssignment = $ProfileAssignment | ConvertTo-Json
    Invoke-MerakiNetworkWirelessAssignEthernetPortsProfile -AuthToken "your-api-token" -NetworkId "1234" -ProfileAssignment $ProfileAssignment
 
    This example assigns a network wireless Ethernet ports profile 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 assignment is successful, otherwise, it displays an error message.
    #>

    
        [CmdletBinding()]
        param (
            [parameter(Mandatory=$true)]
            [string]$AuthToken,
            [parameter(Mandatory=$true)]
            [string]$NetworkId,
            [parameter(Mandatory=$true)]
            [string]$ProfileAssignment
        )
    
        try {
            $header = @{
                "X-Cisco-Meraki-API-Key" = $AuthToken
                "content-type" = "application/json; charset=utf-8"
            }
    
            $url = "https://api.meraki.com/api/v1/networks/$NetworkId/wireless/ethernet/ports/profiles/assign"
    
            $body = $ProfileAssignment
    
            $response = Invoke-RestMethod -Method Post -Uri $url -headers $header -UserAgent "MerakiPowerShellModule/1.1.0 DocNougat" -Body $body
            return $response
        }
        catch {
        Write-Debug $_
        Throw $_
    }
    }