Public/ManagementClientProfiles/Add-ManagementClientProfile.ps1

#Requires -Modules 'MilestonePSTools'

function Add-ManagementClientProfile {
    <#
    .SYNOPSIS
        Adds a new Management Client Profile based on the Default profile
    .DESCRIPTION
        Adds a new Management Client Profile based on the Default profile
    .EXAMPLE
        PS C:\> Add-ManagementClientProfile -Name 'Remote Guards' -Description 'Management Client Profile for Remote Guard users with limited access'
        Creates a new Management Client Profile named 'Remote Guards'
    .OUTPUTS
        The output of this function will be a [VideoOS.Management.VmoClient.ManagementClientProfile] object
        with the following properties:
 
        Name : Default Management Client UI Profile
        Description :
        LastModified : 3/19/2020 10:26:13 PM
        SettingsXml : <Settings />
        IsDefaultProfile : True
        AttachedRoles : { Administrators }
        Id : ee8861e1-b6d5-4afc-b30b-ca63b2d99f3c
        IsDirty : False
        IsCreated : True
        IsDeleted : False
        Exists : True
        CustomProperties : {}
        IsCustomPropertiesSupported : True
        ServerVersion : 20.3.1
    #>

    [CmdletBinding()]
    [OutputType([VideoOS.Management.VmoClient.ManagementClientProfile])]
    param(
        # Specifies the display name the new Management Client Profile
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]
        $Name,
        # Specifies the description for the new Management Client Profile
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]
        $Description
    )

    begin {
        $vmo = Get-VmoClient
    }

    process {
        try {
            $TemplateProfile = Get-ManagementClientProfile | Where-Object IsDefaultProfile
            Write-Verbose "Creating a new Management Client Profile based on profile '$($TemplateProfile.Name)'"
            $newProfile = [VideoOS.Management.VmoClient.ManagementClientProfile]::new($vmo.ManagementServer)
            $newProfile.Name = $Name
            $newProfile.Description = $Description
            $newProfile.SettingsXml = $TemplateProfile.SettingsXml
            $newProfile.Create()
            if ($newProfile.IsCreated) {
                Write-Output $newProfile
            }
        }
        catch {
            $vmo.Dispose()
            throw
        }
    }

    end {
        $vmo.Dispose()
    }
}