Public/Set-MerakiNetworkVLANProfilesAssignments.ps1

function Set-MerakiNetworkVLANProfilesAssignments {
    <#
    .SYNOPSIS
    Reassigns VLAN profile assignments for a network using the Meraki Dashboard API.
 
    .DESCRIPTION
    The Set-MerakiNetworkVLANProfilesAssignments function allows you to reassign VLAN profile assignments for a network by providing the authentication token, network ID, and a JSON configuration for the VLAN profile assignments.
 
    .PARAMETER AuthToken
    The authentication token (API key) required to access the Meraki Dashboard API.
 
    .PARAMETER NetworkId
    The ID of the Meraki network for which you want to reassign VLAN profile assignments.
 
    .PARAMETER VLANProfileAssignment
    The JSON configuration for the VLAN profile assignments to be reassigned. Refer to the JSON schema for required parameters and their format.
 
    .EXAMPLE
    $VLANProfileAssignment = [PSCustomObject]@{
        vlanProfile = @{
            iname = "Profile1"
        }
        serials = @("Q234-ABCD-5678")
        stackIds = @("1234")
    }
 
    $VLANProfileAssignment = $VLANProfileAssignment | ConvertTo-Json -Compress
 
    Set-MerakiNetworkVLANProfilesAssignments -AuthToken "your-api-token" -NetworkId "L_123456789012345678" -VLANProfileAssignment $VLANProfileAssignment
 
    This example reassigns the VLAN profile assignments for the Meraki network with ID "L_123456789012345678" 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 reassignment is successful, otherwise, it displays an error message.
    #>


    [CmdletBinding()]
    param (
        [parameter(Mandatory=$true)]
        [string]$AuthToken,
        [parameter(Mandatory=$true)]
        [string]$NetworkId,
        [parameter(Mandatory=$true)]
        [string]$VLANProfileAssignment
    )
    try {
        $header = @{
            "X-Cisco-Meraki-API-Key" = $AuthToken
            "content-type" = "application/json; charset=utf-8"
        }
        
        $body = $VLANProfileAssignment

        $url = "https://api.meraki.com/api/v1/networks/$NetworkId/vlanProfiles/assignments/reassign"
        
        $response = Invoke-RestMethod -Method Post -Uri $url -headers $header -UserAgent "MerakiPowerShellModule/1.0.8 DocNougat" -Body $body
        return $response
    }
    catch {
        Write-Debug $_
        Throw $_
    }
}