Public/ManagementClientProfiles/Remove-ManagementClientProfile.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
#Requires -Modules 'MilestonePSTools'

function Remove-ManagementClientProfile {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
    param (
        # Specifies the Management Client Profile to Remove
        [Parameter(Mandatory, ValueFromPipeline, ParameterSetName='ByObject')]
        [VideoOS.Management.VmoClient.ManagementClientProfile[]]
        $ManagementClientProfile,
        [Parameter(Mandatory, ValueFromPipeline, ParameterSetName='ByName')]
        [string]
        $Name
    )

    begin {
        $vmo = Get-VmoClient
    }

    process {
        try {

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

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

    end {
        $vmo.Dispose()
    }
}