Public/Set-MerakiNetworkApplianceSecurityMalware.ps1

function Set-MerakiNetworkApplianceSecurityMalware {
    <#
    .SYNOPSIS
    Updates the security malware settings for a Meraki network using the Meraki Dashboard API.
 
    .DESCRIPTION
    The Set-MerakiNetworkApplianceSecurityMalware function allows you to update the security malware settings for a specified Meraki network by providing the authentication token, network ID, and a malware configuration string.
 
    .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 update the security malware settings.
 
    .PARAMETER MalwareConfig
    A string containing the malware configuration. The string should be in JSON format and should include the "mode", "allowedFiles", and "allowedUrls" properties.
 
    .EXAMPLE
    $config = [PSCustomObject]@{
        mode = "enabled"
        allowedUrls = @(
            @{
                url = "example.org"
                comment = "allow example.org"
            },
            @{
                url = "help.com.au"
                comment = "allow help.com.au"
            }
        )
        allowedFiles = @(
            @{
                sha256 = "e82c5f7d75004727e1f3b94426b9a11c8bc4c312a9170ac9a73abace40aef503"
                comment = "allow ZIP file"
            }
        )
    }
 
    $config = $config | ConvertTo-Json -Compress
    Set-MerakiNetworkApplianceSecurityMalware -AuthToken "your-api-token" -NetworkId "your-network-id" -MalwareConfig $config
 
    This example updates the security malware settings for the Meraki network with ID "your-network-id", using the specified malware configuration.
 
    .NOTES
    The function requires the "Invoke-RestMethod" cmdlet to be available.
 
    The function returns the response from the API if the security malware settings 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]$MalwareConfig
    )

    try {
        $header = @{
            "X-Cisco-Meraki-API-Key" = $AuthToken
            "content-type" = "application/json; charset=utf-8"
        }

        $body = $MalwareConfig

        $uri = "https://api.meraki.com/api/v1/networks/$NetworkId/appliance/security/malware"
        $response = Invoke-RestMethod -Method Put -Uri $uri -headers $header -UserAgent "MerakiPowerShellModule/1.0.8 DocNougat" -Body $body
        return $response
    }
    catch {
        Write-Debug $_
        Throw $_
    }
}