Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Add-Log {
- param (
- [String]$requester,
- [String]$message,
- [String]$type
- )
- # Testing is done on a locally running version of the dashboard, ie; not a server.
- if ($ENV:COMPUTERNAME -notlike "*SRV*") {
- $test = "TEST "
- }
- if ($requester -notlike "*SYSTEM*") {
- $requester = $requester.Split("\")[1]
- }
- if ($type -eq $null) {
- $type = "Error"
- }
- # Knowing when something is done is useful.
- $timestamp = Get-Date
- # IF it is on the testing instance, this will append "TEST " to the front of the requester name.
- $requester = $test + $requester
- $params = @{"ts"=$timestamp; "u"=$requester; "m"=$message; "t"=$type}
- "INSERT INTO log_table (time, account, message, type) VALUES (@ts, @u, @m, @t);" | Invoke-PostgreSqlQuery -Parameters $params -ConnectionString $ConfigurationFile.Dashboard.ConnectionString -CUD
- }
Advertisement
Add Comment
Please, Sign In to add comment