PoshCode Archive  Artifact [51226ed934]

Artifact 51226ed934effcb85f87e6b888ddbcfe2bfcfe2acf5ea72e67a4a03c52f34923:

  • File New-CustomColumn.ps1 — part of check-in [f195c6950f] at 2018-06-10 14:24:31 on branch trunk — New-CustomColumn for PowerShell V1.0 (user: unknown size: 1131)

# encoding: ascii
# api: powershell
# title: New-CustomColumn ()
# description: New-CustomColumn for PowerShell V1.0
# version: 1.0
# type: function
# license: CC0
# function: New-CustomColumn
# x-poshcode-id: 828
# x-archived: 2009-02-04T17:14:04
#
#
# Function New-CustomColumn for PowerShell V1.0
#
# Helper function to create Custom Columns for select or format cmdlets
# for more info and examples see :
# http://thepowershellguy.com/blogs/posh/archive/2009/01/26/new-customcolumn-function-powershell-v1-0.aspx
#
# /\/\o\/\/ 2008
# http://thePowerShellGuy.com

Function New-CustomColumn {
  PARAM (
    $Expression,
    $name,
    $label,
    $FormatString,
    [int]$Width,
    $Alignment
  )

  $column = @{}

  if ($Expression){
    $Column.Expression = $Expression
  } else {
    throw "Expression is mandatory"
  }
  if ($Name) {$Column.Name = $name}
  if ($Label) {$Column.Label = $Label}
  if ($FormatString) {$Column.FormatString = $FormatString}
  if ($Width) {$Column.Width = $Width}
  if ($Alignment) {$Column.Alignment = $Alignment}

  $Column.psobject.baseobject

}