Get-ConsoleConfig.ps1


Description

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).

Back to Top

Usage

Example 1

PS C:\> Get-ConsoleConfig

Retrieves the current console window and buffer sizes.

Back to Top

Notes

Author: Your Name Date: 2024-06-30

Back to Top


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

Back to Top

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.

Issue


Back to Top