Last active
August 29, 2015 14:18
-
-
Save halr9000/28000e6767199e436e97 to your computer and use it in GitHub Desktop.
Splunk Stream helper module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .Synopsis | |
| Returns XML object for local stream forwarder configuration if it exists, or optionally, default configuration. | |
| .DESCRIPTION | |
| Long description | |
| .EXAMPLE | |
| Get-StreamForwarderConfigXml -DefaultConfig | |
| xml CmConfig | |
| --- -------- | |
| version="1.0" encoding="UTF-8" CmConfig | |
| #> | |
| function Get-StreamForwarderConfigXml { | |
| [CmdletBinding()] | |
| [OutputType([System.Xml.XmlDocument])] | |
| param ( | |
| $SplunkHome = $env:SPLUNK_HOME, | |
| [switch]$DefaultConfig | |
| ) | |
| $streamTA = 'Splunk_TA_stream' | |
| if ( !$SplunkHome ) { | |
| $SplunkHome = Join-Path -Path $env:ProgramFiles -ChildPath "Splunk" -Resolve # Resolve flag throws exception if path doesn't exist | |
| } | |
| $StreamTAPath = Join-Path -Path $SplunkHome -ChildPath ( "etc\apps\" + $streamTA ) -Resolve | |
| # Does a local streamfwd.xml file exist? | |
| if ( Test-Path ( $StreamTAPath + "\local\streamfwd.xml" ) ) { | |
| Write-Verbose "Found local streamfwd.xml" | |
| [xml]$out = Get-Content ( $StreamTAPath + "\local\streamfwd.xml" ) | |
| } elseif ( $DefaultConfig ) { | |
| Write-Verbose "No local streamfwd.xml found" | |
| [xml]$out = Get-Content ( $StreamTAPath + "\default\streamfwd.xml" ) | |
| } | |
| # Write the output to stdout so that user can do what they like with it | |
| Write-Output $out | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment