Using Powershell to find only those global holidays that occur today

Viewed 188

I'm new to using Powershell and I'm trying to scrape a website to find ONLY those global holidays occurring today, using the website below.

https://eresearch.fidelity.com/eresearch/markets_sectors/global/holidayCalendar.jhtml

Here is what I've got so far, any help would be greatly appreciated!

$a = Get-Date -UFormat "%m/%d/%y" #to get the date in mm/dd/yy format
$source = "https://eresearch.fidelity.com/eresearch/markets_sectors/global/holidayCalendar.jhtml"
$result = Invoke-WebRequest $source
$d = $result.AllElements | Where Class -eq "layout-calendar-content-column" | Select -ExpandProperty innerText 

echo $d

Ideally, it would only show those holidays that match the date contained in the variable $a.

1 Answers

Your script is almost complete. Instead of your echo statement, try this:

$d -split "`n" | ? { $_ -like "*$a*" }

Update: For your use-case

($d | Out-String) -split "`n" | Where-Object { $_ -like "*$a*" }
Related