Public/Set-IntuneBrand.ps1

<#
 
.COPYRIGHT
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
See https://github.com/microsoftgraph/powershell-intune-samples/blob/master/LICENSE for license information.
 
#>


Function Set-IntuneBrand() {
    
        <#
    .SYNOPSIS
    This function is used to set the Company Intune Brand resource using the Graph API REST interface
    .DESCRIPTION
    The function connects to the Graph API Interface and sets the Company Intune Brand Resource
    .EXAMPLE
    Set-IntuneBrand -JSON $JSON
    Sets the Company Intune Brand using Graph API
    .NOTES
    NAME: Set-IntuneBrand
    #>

    
        [cmdletbinding()]
    
        param
        (
            $JSON
        )
    
        $graphApiVersion = "Beta"
        $App_resource = "deviceManagement"
    
        try {
    
            if (!$JSON) {
    
                write-host "No JSON was passed to the function, provide a JSON variable" -f Red
                break
    
            }
    
            else {
    
                Test-JSON -JSON $JSON
    
                $uri = "https://graph.microsoft.com/$graphApiVersion/$($App_resource)"
                Invoke-RestMethod -Uri $uri -Method Patch -ContentType "application/json" -Body $JSON -Headers $authToken
    
            }
    
        }
    
        catch {
    
            $ex = $_.Exception
            $errorResponse = $ex.Response.GetResponseStream()
            $reader = New-Object System.IO.StreamReader($errorResponse)
            $reader.BaseStream.Position = 0
            $reader.DiscardBufferedData()
            $responseBody = $reader.ReadToEnd();
            Write-Host "Response content:`n$responseBody" -f Red
            Write-Error "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)"
            
            break
    
        }
    
    }