Private/GetBaseIdentityType.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
function GetBaseIdentityType {
    <#
        .SYNOPSIS
            A helper function to figure out if the base identity is the name of the base or the ID
    
        .EXAMPLE
            PS> GetBaseIdentityType -Identity 'appXXXXXXXXXXXXXX'
    
    #>

    [OutputType('string')]
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [Alias('BaseName', 'BaseId')]
        [string]$Identity
    )

    $ErrorActionPreference = 'Stop'

    if ($Identity -match '^app[a-zA-Z0-9]{14}$') {
        'ID'
    } else {
        'Name'
    }
}