Get-ConsoleConfig.ps1
19 Sep 2025Description
Purpose
Retrieves the current console window and buffer sizes.
Detailed Description
This function retrieves and returns the current console window size (height and width) and buffer size (height and width).
Usage
Example 1
PS C:\> Get-ConsoleConfig
Retrieves the current console window and buffer sizes.
Notes
Author: Your Name Date: 2024-06-30
Script
function Get-ConsoleConfig {
<#
.SYNOPSIS
Retrieves the current console window and buffer sizes.
.DESCRIPTION
This function retrieves and returns the current console window size (height and width) and buffer size (height and width).
.EXAMPLE
PS C:\> Get-ConsoleConfig
Retrieves the current console window and buffer sizes.
.NOTES
Author: Your Name
Date: 2024-06-30
#>
[CmdletBinding()]
param ()
begin {
Write-Verbose "Starting to retrieve the console settings."
}
process {
try {
$windowHeight = [System.Console]::WindowHeight
$windowWidth = [System.Console]::WindowWidth
$bufferHeight = [System.Console]::BufferHeight
$bufferWidth = [System.Console]::BufferWidth
Write-Verbose "Successfully retrieved console settings."
[PSCustomObject]@{
WindowHeight = $windowHeight
WindowWidth = $windowWidth
BufferHeight = $bufferHeight
BufferWidth = $bufferWidth
}
}
catch {
Write-Error "Failed to retrieve console configuration. Error: $_"
}
}
end {
Write-Verbose "Completed retrieving the console settings."
}
}
# Example usage:
# Get-ConsoleConfig
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.