Is there a way to use Powershell to get a list of Solr cores running in my local instance of Solr? I am running Solr 4.10.1, and am using Powershell 2.0.
I would like to create a text file of core names:
somecore1
somecore2
etc.
I was able to get a list of my cores in XML format by hitting this URL: http://localhost:8983/solr/admin/cores The pertinent details of the return XML are:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2663</int>
</lst>
<str name="defaultCoreName">collection1</str>
<lst name="initFailures"/>
<lst name="status">
<lst name="somecore1">
<!-- Details removed -->
</lst>
<lst name="somecore2">
<!-- Details removed -->
</lst>
</lst>
</response>
First, you need to load the XML response to an XML variable:
Now you can output the list of cores with this syntax:
This syntax states, "In XML document, get child of root element "response", then take the third child "lst", then iterate through its children and output the "name" attribute.
To save as a file, redirect:
Notes: