Store table output in multiple variables?

So the goal is this.

We query an XML for data - and get something like yyyy-MM-dd.XXXX as a return from the element attribute we hit. (Already working.)

We then plug that into a $ReportURLdate variable, and visit https://www.IP.address/URLGibberish&File=$ReportURLdate using CURL.

This works fine when we return one value for $ReportURLdate, but sometimes we get the below when we return it.



And so on. (There could be 4-5 results for a single “Day”.)


How would I go about putting each of these results into their own variable, and then hitting the URL for each variable?

Could I dump them to a table and create a variable for each line with data?


I’m trying to use something like this, but it just isn’t working. (We are specifically looking for a string in this file with YESTERDAY’S date. It will have a random three number string on the end, like so.


$Date = Get-Date
$Date2 = $Date.adddays(-1).tostring("yyyy-MM-dd")

$reportdate = "$date2.*"

Later on, we try to define $ReportURLdate

$ReportURLDay = Get-Content ./dates.txt | Where-Object { $_.Contains("$reportdate")}

This returns a null value.


I’m at my limits here with my skillsets.

I tried using regex, but it’s telling me there’s no overload for argument count.

If I could get a simple \d{3} regex working on this, I’d be closer to where I need to be with storing out the variables.


Any ideas?


If I got you right, when you get multiple values in return, then its an array. You can use foreach loop to iterate through and plug it with the URL.

A simple example.

$Array = 1..5 # your xml query here.
Foreach($Number in $Array) {
   "Current item is $Number"

-Edit -

Issue resolved.

We found another XML attribute we could narrow the scope of results down with.

We’re now narrowing down to a single result with the “period” element of “2”. Headache receding.

$XPath = '//PARENTELEMENT/ELEMENT2/ELEMENT3[@name="period" and text()="2"]/../ELEMENT3[@name="filename"]'
Select-Xml -Xml $xmldoc2 -XPath $XPath | foreach {$_.Node.InnerXml} | out-file ./uniquedates.txt