Public/Set-ConsoleSize.ps1

1
2
3
4
5
6
7
8
9
10
11
12
function Set-ConsoleSize {
  [CmdletBinding()]
  [Alias('FixCon')]
  param(
    [int]$Width = 145,
    [int]$Height = 45
  )
  if ($env:WT_SESSION) {throw 'Does Not Work in Microsoft Terminal'}
  if ($Host.Name -notmatch 'ConsoleHost') {break}
  [console]::SetWindowSize($Width,$Height)
}