<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to list forward-server in PowerShell? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264519#M50794</link>
    <description>&lt;P&gt;&lt;A href="http://dev.splunk.com/view/splunk-powershell-resource-kit/SP-CAAADRU"&gt;http://dev.splunk.com/view/splunk-powershell-resource-kit/SP-CAAADRU&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;See the link here for powershell modules.  I reformatted my powershell code above so it will copy and paste better.  Please try it again if you like, or use the powershell resource kit from splunk.&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2016 12:23:06 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2016-05-26T12:23:06Z</dc:date>
    <item>
      <title>How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264511#M50786</link>
      <description>&lt;P&gt;I'm trying to list all forwarders by using &lt;CODE&gt;list forward-server&lt;/CODE&gt; command in PowerShell, but not able to execute this command.&lt;/P&gt;

&lt;P&gt;Could you please let me know which module needs to be imported into the script to use list forward-server command?&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 14:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264511#M50786</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2016-05-25T14:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264512#M50787</link>
      <description>&lt;P&gt;Find any powershell doc which tells you how to run an executable/command (splunk.exe list forwarder-server).&lt;/P&gt;

&lt;P&gt;&lt;A href="http://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx"&gt;http://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:48:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264512#M50787</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-25T15:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264513#M50788</link>
      <description>&lt;P&gt;Thanks for the response&lt;/P&gt;

&lt;P&gt;but this is not working &lt;/P&gt;

&lt;P&gt;I tried as below&lt;/P&gt;

&lt;P&gt;c:\ProgramFiles\SplunkUniversalForwarder\bin\splunk.exe list forward-server&lt;/P&gt;

&lt;P&gt;its throwing an error message.&lt;/P&gt;

&lt;P&gt;Pelase advice on this&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 16:07:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264513#M50788</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2016-05-25T16:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264514#M50789</link>
      <description>&lt;P&gt;What is the error message you get? this command requires authentication as well, you would have to run like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;c:\ProgramFiles\SplunkUniversalForwarder\bin\splunk.exe list forward-server -auth username:password
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2016 16:25:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264514#M50789</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-25T16:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264515#M50790</link>
      <description>&lt;P&gt;This is working fine from the PS terminal but I just used list forward-server command in ps script ..its not working&lt;/P&gt;

&lt;P&gt;$ServerName = get-content "c:\serverlist.txt"&lt;/P&gt;

&lt;P&gt;foreach ($Server in $ServerName) {&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   if (test-Connection -ComputerName $Server -Count 2 -Quiet -cred $cred) {

          write-Output "$Server is up."



          $rv = Invoke-Command -ScriptBlock {

                 $splunk = ' C:\Program Files\splunkUniversalforwarder\bin\splunk.exe'

                 &amp;amp; $splunk list forward-server



    } -Computername $Server

    Write-Output $rv



   } else {

          Write-Warning "$Server not responding"

   }  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 20:10:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264515#M50790</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2016-05-25T20:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264516#M50791</link>
      <description>&lt;P&gt;What error you get?&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 20:23:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264516#M50791</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-25T20:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264517#M50792</link>
      <description>&lt;P&gt;Splunk.exe spits out some weird stuff thats hard to wrap up.  Its actually easier to get the list from the api or to use the splunk powershell sdk.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/400602/how-to-create-a-powershell-script-to-list-forwarde.html#answer-401987"&gt;https://answers.splunk.com/answers/400602/how-to-create-a-powershell-script-to-list-forwarde.html#answer-401987&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;add-type @"
using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } 
"@ 

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy 
$user = "admin" 
$pass = convertto-securestring -AsPlainText -Force -String 'admin' #your password here 
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user,$pass 
$request = Invoke-WebRequest -uri &lt;A href="https://localhost:8089/services/data/outputs/tcp/default" target="test_blank"&gt;https://localhost:8089/services/data/outputs/tcp/default&lt;/A&gt; -credential $cred 
$request.Content 
$request = Invoke-WebRequest -uri &lt;A href="https://localhost:8089/services/data/outputs/tcp/group" target="test_blank"&gt;https://localhost:8089/services/data/outputs/tcp/group&lt;/A&gt; -credential $cred 
$request.Content 
$request = Invoke-WebRequest -uri &lt;A href="https://localhost:8089/services/data/outputs/tcp/server" target="test_blank"&gt;https://localhost:8089/services/data/outputs/tcp/server&lt;/A&gt; -credential $cred 
$request.Content
$request = Invoke-WebRequest -uri &lt;A href="https://localhost:8089/services/data/outputs/tcp/allconnections" target="test_blank"&gt;https://localhost:8089/services/data/outputs/tcp/allconnections&lt;/A&gt; -credential $cred 
$request.Content
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 May 2016 02:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264517#M50792</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-26T02:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264518#M50793</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;This is not executing.. Im looking for powershell script which will return list of forwarders&lt;/P&gt;

&lt;P&gt;Is there any module available to use splunk list forward-server command in power shell script&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 08:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264518#M50793</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2016-05-26T08:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264519#M50794</link>
      <description>&lt;P&gt;&lt;A href="http://dev.splunk.com/view/splunk-powershell-resource-kit/SP-CAAADRU"&gt;http://dev.splunk.com/view/splunk-powershell-resource-kit/SP-CAAADRU&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;See the link here for powershell modules.  I reformatted my powershell code above so it will copy and paste better.  Please try it again if you like, or use the powershell resource kit from splunk.&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 12:23:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264519#M50794</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-26T12:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264520#M50795</link>
      <description>&lt;P&gt;Taking it a step further using invoke-restmethod:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$user = "admin" 
$pass = convertto-securestring -AsPlainText -Force -String 'admin' #your password here 
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user,$pass 
$request = Invoke-RestMethod -uri &lt;A href="https://localhost:8089/services/data/outputs/tcp/server" target="test_blank"&gt;https://localhost:8089/services/data/outputs/tcp/server&lt;/A&gt; -credential $cred 
$request.title
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 May 2016 12:51:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264520#M50795</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-26T12:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to list forward-server in PowerShell?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264521#M50796</link>
      <description>&lt;P&gt;Thanks somesoni2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;c:\ProgramFiles\SplunkUniversalForwarder\bin\splunk.exe list forward-server -auth username:password
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Worked for me for supplying creds, however I am not using powershell to call this...  instead I am using winexe from Linux.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 20:13:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-list-forward-server-in-PowerShell/m-p/264521#M50796</guid>
      <dc:creator>TonyLeeVT</dc:creator>
      <dc:date>2017-04-18T20:13:07Z</dc:date>
    </item>
  </channel>
</rss>

