Get-ConsoleWidth.ps1

function Get-ConsoleWidth
{
  <#
    .SYNOPSIS
    Returns the width of the current PowerShell Console
    .DESCRIPTION
    Returns the width of the current PowerShell Console
    .EXAMPLE
    Get-ConsoleWidth
    Prints out the current console width
    .EXAMPLE
    $width = Get-ConsoleWidth
    Stores the Console Width into the $width variable.
  #>

  $width = (Get-Host).UI.RawUI.BufferSize.Width
  return $width
}