Public/SmartClientProfiles/Remove-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
#Requires -Modules 'MilestonePSTools'
function Remove-SmartClientProfile {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
    param (
        # Specifies the Smart Client Profile to Remove
        [Parameter(Mandatory, ValueFromPipeline, ParameterSetName='ByObject')]
        [VideoOS.Management.VmoClient.SmartClientProfile[]]
        $SmartClientProfile,
        [Parameter(Mandatory, ValueFromPipeline, ParameterSetName='ByName')]
        [string]
        $Name
    )

    begin {
        $vmo = Get-VmoClient
    }

    process {
        try {

            if ($null -eq $SmartClientProfile) {
                $SmartClientProfile = Get-SmartClientProfile -Name $Name
            }

            foreach ($profile in $SmartClientProfile) {
                if ($PSCmdlet.ShouldProcess("Smart Client Profile '$($profile.Name)'",'Remove')) {
                    $profile.Delete()
                }
            }
        }
        catch {
            $vmo.Dispose()
            throw
        }
    }

    end {
        $vmo.Dispose()
    }
}