Functions/Test-IsNumLock.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
function Test-IsNumLock {
<#
.SYNOPSIS
    Determines the state of NumLock
.DESCRIPTION
    Determines the state of the NumLock. Optional -Verbose argument
.EXAMPLE
    Test-IsNumLock
.EXAMPLE
    Test-IsNumLock -Verbose
.OUTPUTS
    bool
.NOTES
    Inspiration: # Inspired by https://gallery.technet.microsoft.com/on-off-keyboad-lock-keys-6ba9885c
#>


    [CmdletBinding(ConfirmImpact='None')]
    [OutputType('bool')]
    Param()

    Begin {
        Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]"
    }

    process {
        write-verbose -Message 'Determining the state of [NumLock]'
        $ReturnVal = [console]::NumberLock
        Write-Output -InputObject $ReturnVal
    }

    end {
        Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]"
    }
}