First, yes I am a noob to scripting and powershell as that will become painfully obvious. In my attempts to learn, I have been working with a script from here: http://www.leeholmes.com/blog/2010/03/05/html-agility-pack-rocks-your-screen-scraping-world/
This is what I have thus far:
add-type -Path 'C:\Program Files (x86)\htmlAgilityPack\HtmlAgilityPack.dll'
$doc = New-Object HtmlAgilityPack.HtmlDocument
$result = $doc.Load("C:\scipts\test.html")
$texts = $doc.DocumentNode.SelectNodes("//table[@class='dataTable']/tbody/tr/td[1]/a[1]")
$result = $texts | % {
$testText = $_
$Platform = $testtext.innertext
New-Object PsObject -Property @{ Platform = $Platform} | Select Platform
}
$result | Sort Platform | out-string
This gives me the items I am looking for.
* The Challenge *
I am trying to get that output into a variable as a single string with each item followed by a comma. for Example Item1, Item2, Item 3 etc…
Any help or explanation would be appreciated as I have Googled myself cross-eyed and don’t necessarily stand the things I am finding.
Thanks!
From the powershell help (
get-help about_join):To solve your problem, you need to:
Create an array of strings containing the strings you want to join:
Join the strings using a comma as the delimiter:
$joinedstringwill containItem1, Item2, Item3