-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGet-ConsoleWindowSize.ps1
38 lines (31 loc) · 1.04 KB
/
Get-ConsoleWindowSize.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
function Get-ConsoleWindowSize {
<#
.SYNOPSIS
Gets the current the window size and buffer size of the current console window
.DESCRIPTION
Gets the current the window size and buffer size of the current console window
.EXAMPLE
Get-ConsoleWindowSize
BufferWidth BufferHeight WindowWidth WindowHeight
----------- ------------ ----------- ------------
196 32766 196 21
#>
[CmdletBinding()]
param()
begin {
Write-Verbose -Message "Starting [$($MyInvocation.MyCommand)]"
}
process {
$console = $Host.UI.RawUI
$result = New-Object -TypeName psobject -Property ([ordered] @{
BufferWidth = $console.BufferSize.Width
BufferHeight = $console.BufferSize.Height
WindowWidth = $console.WindowSize.Width
WindowHeight = $console.WindowSize.Height
})
Write-Output -InputObject $result
}
end {
Write-Verbose -Message "Ending [$($MyInvocation.MyCommand)]"
}
}