Public/SmartClientProfiles/Add-SmartClientProfile.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#Requires -Modules 'MilestonePSTools'

function Add-SmartClientProfile {
    <#
    .SYNOPSIS
        Adds a new Smart Client Profile based on the Default profile
    .DESCRIPTION
        Adds a new Smart Client Profile based on the Default profile
    .EXAMPLE
        PS C:\> Add-SmartClientProfile -Name 'Remote Guards' -Description 'Smart Client Profile for Remote Guard users with limited access'
        Creates a new Smart Client Profile named 'Remote Guards'
    .OUTPUTS
        The output of this function will be a [VideoOS.Management.VmoClient.SmartClientProfile] 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 the new Smart Client Profile
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]
        $Name,
        # Specifies the description for the new Smart Client Profile
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]
        $Description,
        # Specifies the description for the new Smart Client Profile
        [Parameter()]
        [VideoOS.Management.VmoClient.SmartClientProfile]
        $TemplateProfile
    )

    begin {
        $vmo = Get-VmoClient
    }

    process {
        try {
            $TemplateProfile = Get-SmartClientProfile | Where-Object IsDefaultProfile
            Write-Verbose "Creating a new Smart Client Profile based on profile '$($TemplateProfile.Name)'"
            $newProfile = [VideoOS.Management.VmoClient.SmartClientProfile]::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()
    }
}