<?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 Splunk powershell in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-powershell/m-p/504901#M86025</link>
    <description>&lt;P&gt;Here we are using a PowerShell script to extract the data from the AD subnets from a windows server&lt;/P&gt;&lt;P&gt;This is scheduled to run once every week to pull the list of subnets on a particular root domain&lt;/P&gt;&lt;P&gt;We are supposed to get the results only from a parent domain, instead we are getting the results from the subdomains which is not the expected result.&lt;/P&gt;&lt;P&gt;Also when we run the Script in PowerShell ISE directly we are getting a list of subnets from a domain , but the result we see in splunk is entirely different from different domains than the results we get while running the script locally&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Since the results contains the subnets and IP Address we are unable to attach the screenshot due to the sensitivity of the results.&lt;/P&gt;&lt;P&gt;Script used “&lt;/P&gt;&lt;P&gt;# extract domain rootDNS&lt;BR /&gt;$domain=$([adsi] "LDAP://RootDSE").Get("rootDomainNamingContext") -replace "DC=","" -replace ",","."&lt;/P&gt;&lt;P&gt;# create LDAP path for AD subnets&lt;BR /&gt;$subnetsDN="LDAP://CN=Subnets,CN=Sites," + $([adsi] "LDAP://RootDSE").Get("ConfigurationNamingContext")&lt;/P&gt;&lt;P&gt;#ouput properties&lt;BR /&gt;$props = @{domain=$domain;ip="";sitename=""}&lt;/P&gt;&lt;P&gt;# get subnets and loop through list&lt;BR /&gt;foreach ($subnetDN in $([adsi] $subnetsDN).psbase.children){&lt;BR /&gt;$tmpTable = new-object psobject -property $props&lt;BR /&gt;# get CN of the subnet's site objects&lt;BR /&gt;$tmpTable.sitename=$([adsi] "LDAP://$($subnetDN.siteObject)").cn.tostring()&lt;BR /&gt;# validate sitename&lt;BR /&gt;if($tmpTable.sitename -ne $null){&lt;BR /&gt;#extract subnet CN&lt;BR /&gt;$tmpTable.ip=$subnetDN.cn.tostring()&lt;BR /&gt;#write output&lt;BR /&gt;$tmpTable |select domain, ip, sitename&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Input Stanza:&lt;/P&gt;&lt;P&gt;[powershell://Get-ADSubnets]&lt;BR /&gt;script = . "$SplunkHome\etc\apps\bhp_hf_ad_audit_powershell_subnet\bin\RunAudit-ADSubnets.ps1"&lt;BR /&gt;schedule = 30 15 * * 0&lt;BR /&gt;sourcetype = microsoft:ad:subnets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 06:49:03 GMT</pubDate>
    <dc:creator>arunsundarm</dc:creator>
    <dc:date>2020-06-18T06:49:03Z</dc:date>
    <item>
      <title>Splunk powershell</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-powershell/m-p/504901#M86025</link>
      <description>&lt;P&gt;Here we are using a PowerShell script to extract the data from the AD subnets from a windows server&lt;/P&gt;&lt;P&gt;This is scheduled to run once every week to pull the list of subnets on a particular root domain&lt;/P&gt;&lt;P&gt;We are supposed to get the results only from a parent domain, instead we are getting the results from the subdomains which is not the expected result.&lt;/P&gt;&lt;P&gt;Also when we run the Script in PowerShell ISE directly we are getting a list of subnets from a domain , but the result we see in splunk is entirely different from different domains than the results we get while running the script locally&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Since the results contains the subnets and IP Address we are unable to attach the screenshot due to the sensitivity of the results.&lt;/P&gt;&lt;P&gt;Script used “&lt;/P&gt;&lt;P&gt;# extract domain rootDNS&lt;BR /&gt;$domain=$([adsi] "LDAP://RootDSE").Get("rootDomainNamingContext") -replace "DC=","" -replace ",","."&lt;/P&gt;&lt;P&gt;# create LDAP path for AD subnets&lt;BR /&gt;$subnetsDN="LDAP://CN=Subnets,CN=Sites," + $([adsi] "LDAP://RootDSE").Get("ConfigurationNamingContext")&lt;/P&gt;&lt;P&gt;#ouput properties&lt;BR /&gt;$props = @{domain=$domain;ip="";sitename=""}&lt;/P&gt;&lt;P&gt;# get subnets and loop through list&lt;BR /&gt;foreach ($subnetDN in $([adsi] $subnetsDN).psbase.children){&lt;BR /&gt;$tmpTable = new-object psobject -property $props&lt;BR /&gt;# get CN of the subnet's site objects&lt;BR /&gt;$tmpTable.sitename=$([adsi] "LDAP://$($subnetDN.siteObject)").cn.tostring()&lt;BR /&gt;# validate sitename&lt;BR /&gt;if($tmpTable.sitename -ne $null){&lt;BR /&gt;#extract subnet CN&lt;BR /&gt;$tmpTable.ip=$subnetDN.cn.tostring()&lt;BR /&gt;#write output&lt;BR /&gt;$tmpTable |select domain, ip, sitename&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Input Stanza:&lt;/P&gt;&lt;P&gt;[powershell://Get-ADSubnets]&lt;BR /&gt;script = . "$SplunkHome\etc\apps\bhp_hf_ad_audit_powershell_subnet\bin\RunAudit-ADSubnets.ps1"&lt;BR /&gt;schedule = 30 15 * * 0&lt;BR /&gt;sourcetype = microsoft:ad:subnets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 06:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-powershell/m-p/504901#M86025</guid>
      <dc:creator>arunsundarm</dc:creator>
      <dc:date>2020-06-18T06:49:03Z</dc:date>
    </item>
  </channel>
</rss>

