Private/Invoke-CmdKey.ps1

function Invoke-CmdKey {
    <#
    .SYNOPSIS
        Wrapper around the 'cmdkey' external command for mockability.
    .DESCRIPTION
        Executes 'cmdkey' with the given arguments and returns the output.
        Using a wrapper function allows Pester to mock this in tests,
        since external executables cannot be mocked directly.
    .PARAMETER Arguments
        The arguments to pass to 'cmdkey'.
    .OUTPUTS
        [string[]] The command output lines.
    #>

    [CmdletBinding()]
    [OutputType([string[]])]
    param(
        [Parameter()]
        [AllowEmptyCollection()]
        [string[]]$Arguments = @()
    )

    if ($Arguments.Count -eq 0) {
        $result = & cmdkey 2>&1
    }
    else {
        $result = & cmdkey @Arguments 2>&1
    }
    return $result
}