PS Standard.ps1: Difference between revisions

From vwiki
Jump to navigation Jump to search
(Initial creation)
 
m (Re-orged categories)
 
Line 38: Line 38:
</source>
</source>


[[Category:PowerShell]]
[[Category:PowerShell_Script]]

Latest revision as of 13:56, 18 April 2012

# ======================================================
# Standard include library (logging etc)
# ======================================================
# Simon Strutt        Nov 2010
# ======================================================
#
# Version 1
# - Initial Creation
#
# Version 2
# - Added error logger
#
# ======================================================

$RGB_RED = "#ff3300"
$RGB_AMBER = "#ff9900"
$RGB_GREEN = "#66ff99"

function Log ($text) {
    [int]$duration = (New-TimeSpan $start (Get-Date)).TotalSeconds
    Write-Host "$duration secs | $text"
}

function Log-NoNewLine ($text) {
    [int]$duration = (New-TimeSpan $start (Get-Date)).TotalSeconds
    Write-Host "$duration secs | $text" -nonewline
}

#function Log-Error($text) {
#    if (!$ErrorLog) {
#        $ErrorLog = @()
#    }
#    $ErrorLog += $text
#    Log ("ERROR: " + $text)
#}