19 lines
528 B
PowerShell
19 lines
528 B
PowerShell
function Get-ConsoleDisplayWidth {
|
|
<#
|
|
.SYNOPSIS
|
|
Get the width of the current UI, if possible
|
|
|
|
.PARAMETER DefaultDisplayWidth
|
|
Supply a value if you want the default to be considered something else
|
|
#>
|
|
param(
|
|
$DefaultDisplayWidth = 80
|
|
)
|
|
|
|
$maxDisplayWidth = $DefaultDisplayWidth
|
|
if (($null -ne $host) -and ($null -ne $host.UI) -and ($null -ne $host.UI.RawUI) -and ($null -ne $host.UI.RawUI.WindowSize)) {
|
|
$maxDisplayWidth = $host.UI.RawUI.WindowSize.Width
|
|
}
|
|
|
|
return $maxDisplayWidth
|
|
} |