Quantcast
Channel: THWACK: Document List - Network Performance Monitor
Viewing all articles
Browse latest Browse all 1956

Send syslog using PowerShell

$
0
0

There was a need to send out syslogs to Orion through DMZ.  The "Kiwi Syslog message generator" did not work, so found a portable way to do this using powershell.   This is a well known script, just had to tweak the date format so that SW syslog understood it.

 

 

$Server = 'x.x.x.x'

$Message = 'From  - PowerShell'

#0=EMERG 1=Alert 2=CRIT 3=ERR 4=WARNING 5=NOTICE  6=INFO  7=DEBUG

$Severity = '1'

#(16-23)=LOCAL0-LOCAL7

$Facility = '22'

$Hostname= 'Test-DC01'

# Create a UDP Client Object

$UDPCLient = New-Object System.Net.Sockets.UdpClient

$UDPCLient.Connect($Server, 514)

# Calculate the priority

$Priority = ([int]$Facility * 8) + [int]$Severity

#Time format the SW syslog understands

$Timestamp = Get-Date -Format "MMM dd HH:mm:ss"

# Assemble the full syslog formatted message

$FullSyslogMessage = "<{0}>{1} {2} {3}" -f $Priority, $Timestamp, $Hostname, $Message

# create an ASCII Encoding object

$Encoding = [System.Text.Encoding]::ASCII

# Convert into byte array representation

$ByteSyslogMessage = $Encoding.GetBytes($FullSyslogMessage)

# Send the Message

$UDPCLient.Send($ByteSyslogMessage, $ByteSyslogMessage.Length)

 

I used this to show the client that the syslogs were actually blocked by the DMZ firewall by running the PowerShell on different subnets.  The good part is that no software installation is needed.

 

Thanks

Amit


Viewing all articles
Browse latest Browse all 1956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>