Public/ManagementClientProfiles/Get-ManagementClientProfile.ps1

#Requires -Modules 'MilestonePSTools'

function Get-ManagementClientProfile {
    <#
    .SYNOPSIS
        Gets one or more Management Client Profile objects including their SettingsXml property which defines all parameters
    .DESCRIPTION
        Working with View Groups is not currently supported in MIP SDK, however the redistributable SDK
        includes an assembly containing the VmoClient which is a component used internally by the SDK
        and applications like XProtect Management Client.
 
        This function makes use of this VmoClient to manipulate the View Groups to enable complex tasks
        required in some environments.
    .EXAMPLE
        PS C:\> Get-ManagementClientProfile -Name 'Remote Guards'
        Gets the Management Client Profile named 'Remote Guards'
    .EXAMPLE
        PS C:\> Get-ManagementClientProfile -Name 'Limited*'
        Gets the Management Client Profile(s) with names beginning with the word 'Limited'
    .OUTPUTS
        The output of this function will be a [VideoOS.Management.VmoClient.ManagementClientProfile] object
        with the following properties:
 
        Name : Remote Guard
        Description :
        LastModified : 1/22/2021 7:59:12 PM
        SettingsXml : <Settings>
                                        <Setting key="SettingKeyName">
                                        <Value>Example</Value>
                                        <Locked>False</Locked>
                                        </Setting>
                                      </Settings>
        IsDefaultProfile : False
        AttachedRoles : {}
        Id : e73e6ddf-8493-48e9-8e48-04b36023538d
        IsDirty : False
        IsCreated : True
        IsDeleted : False
        Exists : True
        CustomProperties : {}
        IsCustomPropertiesSupported : True
        ServerVersion : 20.3.1
    #>

    [CmdletBinding()]
    param(
        # Specifies the display name of the ViewGroup. Wildcards are supported.
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]
        $Name = '*'
    )

    begin {
        $vmo = Get-VmoClient
    }

    process {
        try {
            $profiles = $vmo.ManagementServer.ClientProfileSection.ManagementClientProfiles | Select-Object
            $profiles | Foreach-Object {
                if ($_.Name -like $Name) {
                    Write-Output $_
                    $vmo.ManagementServer.ClientProfileSection.ManagementClientProfiles.Refresh($true)
                }
            }
        }
        catch {
            $vmo.Dispose()
            throw
        }
    }

    end {
        $vmo.Dispose()
    }
}