diff options
Diffstat (limited to 'userphotos/loglib.ps1')
-rwxr-xr-x | userphotos/loglib.ps1 | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/userphotos/loglib.ps1 b/userphotos/loglib.ps1 new file mode 100755 index 0000000..92a5f40 --- /dev/null +++ b/userphotos/loglib.ps1 @@ -0,0 +1,37 @@ +# Filename: \\util201\scripts\Functions\loglib.ps1
+# License: CC-BY-SA 4.0
+# Author: bgstack15, TAFKAC
+# Startdate: 2019-11-25 10:19
+# Title: Logging library
+# Purpose: Provide logging functions
+# History:
+# Usage:
+# Reference:
+# internal file systems-engineering/powershell/deploy-server/iad/library/functions.ps1
+# Improve:
+# Dependencies:
+#
+
+### GLOBAL VARIABLES
+$global:today = Get-Date -Format yyyy-MM-dd
+
+### FUNCTIONS
+Function Log {
+ # adapted from TAFKAC
+ [CmdletBinding()]
+ param (
+ [Parameter(Mandatory = $TRUE, Position = 0)]
+ [string] $entry
+ )
+ If (!($GLOBAL:log -ne $NULL)) {
+ Set-Variable -Name log -Value @() -Scope Global;
+ }
+ $stamp = (Get-Date -Format FileDateTimeUniversal);
+ $GLOBAL:log += "[$stamp] $entry";
+ Write-Host "[$stamp] $entry" -ForegroundColor Gray
+ if ($global:logfile -ne $null)
+ {
+ $logid = ""; if ($global:logid -ne $null) {$logid = " ${global:logid}"}
+ "[$stamp] ${env:UserName}@${env:ComputerName}${logid}: $entry" | Out-File -Append $global:logfile
+ }
+}
|