functions/device/Remove-PSCUCMPhone.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
function Remove-PSCUCMPhone {
    <#
    .SYNOPSIS
    Remove a phone from CUCM
     
    .DESCRIPTION
    Remove a phoen from CUCM
     
    .PARAMETER Name
    Name of phone to remove
     
    .PARAMETER UUID
    UUID of phone to remove
     
    .PARAMETER EnableException
    Parameter description
 
    .PARAMETER WhatIf
    What If?
     
    .PARAMETER Confirm
    Confirm...
     
    .EXAMPLE
    Remove-PSCUCMPhone -UUID {3C33ADA6-70DF-F16C-C5B9-16CE14AE58B3}
 
    Removes phone with UUID {3C33ADA6-70DF-F16C-C5B9-16CE14AE58B3}
 
    #>

    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = "Low")]
    param (
        [Parameter(ParameterSetName = "Name", Mandatory)]
        [string]
        $Name,
        [Parameter(ParameterSetName = "UUID", Mandatory)]
        [string]
        $UUID,
        [Parameter(ParameterSetName = "Name")]
        [Parameter(ParameterSetName = "UUID")]
        [switch]
        $EnableException
    )
    $cucmDeets = Get-PSCUCMStatus
    $invokeCucmAxlSplat = @{
        entity          = 'removePhone'
        EnableException = $EnableException
    }
    if ($PSCmdlet.ParameterSetName -eq 'Name') {
        $invokeCucmAxlSplat.parameters = @{
            name = $name
        }
    }
    if ($PSCmdlet.ParameterSetName -eq 'UUID') {
        $invokeCucmAxlSplat.parameters = @{
            uuid = $UUID
        }
    }
    if ($PSCmdlet.ShouldProcess($cucmDeets.Server, "Remove Phone $Name$UUID")) {
            Invoke-PSCUCMAxlQuery @invokeCucmAxlSplat
        }
    }