Guest User

Untitled

a guest
Jun 24th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Add-Log {
  2.     param (
  3.         [String]$requester,
  4.         [String]$message,
  5.         [String]$type
  6.     )
  7.     # Testing is done on a locally running version of the dashboard, ie; not a server.
  8.     if ($ENV:COMPUTERNAME -notlike "*SRV*") {
  9.         $test = "TEST "
  10.     }
  11.     if ($requester -notlike "*SYSTEM*") {
  12.         $requester = $requester.Split("\")[1]
  13.     }
  14.     if ($type -eq $null) {
  15.         $type = "Error"
  16.     }
  17.     # Knowing when something is done is useful.
  18.     $timestamp = Get-Date
  19.     # IF it is on the testing instance, this will append "TEST " to the front of the requester name.
  20.     $requester = $test + $requester
  21.     $params = @{"ts"=$timestamp; "u"=$requester; "m"=$message; "t"=$type}
  22.     "INSERT INTO log_table (time, account, message, type) VALUES (@ts, @u, @m, @t);" | Invoke-PostgreSqlQuery -Parameters $params -ConnectionString $ConfigurationFile.Dashboard.ConnectionString -CUD
  23. }
Advertisement
Add Comment
Please, Sign In to add comment