Battle Faction Puzzle 3

This topic contains 3 replies, has 4 voices, and was last updated by  Michael 3 months ago.

  • Author
  • #92327

    Axel Bøg Andersen

    Here is a solution that works in 5.1 and 6.0

  • #92341


    I like what Axel is doing. In Puzzle 2 he returned all parameters and then filtered with format file.
    Why we need format file for 9-11 elements? Look on gps (get-process): tabular output 7 properties, but you can get all (~70) if you want. It the battle we want the best needed, but might want more. And without changing the script code.

    "" | %{$feedsResult=(irm $_ | select @{n='Title';e={$_.title}},@{n='Publication Date';e={$_.pubDate}},@{n='Author';e={$_.creator}},@{n='Link';e={$_.Link}}); $feedsResult | ft -a; $titleToOpen=read-host "Copy/Paste Title you want to see"; $textOrBrowser=read-host "Open in [B]rowser or dump to [C]onsole?"; if ($textOrBrowser -eq "B") {start-process ($feedsResult | ? Title -match "$titleToOpen").link} elseif ($textOrBrowser -eq "C") {if ($PSVersionTable.PSEdition -ne "core") {(iwr ($feedsResult | ? Title -match "$titleToOpen").link).allelements | ? class -match entry-content | select -ExpandProperty outerText | fl} else {"`niwr in PSCore ...`n"}} else {write-host -f red "`nWrong choice - exiting...`n"}}

    iwr won't work in 6.0, like in 5.1 because it doesn't support ie's stuff.

    And i killed the puppy, sorry :(. I'm doing this a lot...

  • #92345

    Function Get-FeedArticle {
      param (
      $Feed = [xml](Invoke-WebRequest -Uri "$FeedURI" -usebasicparsing)
      $Items = $ | Sort-Object pubDate -Descending | ForEach-Object {$i=1} {Add-Member -InputObject $_ -MemberType NoteProperty -Name Index -Value ($i++) -PassThru}
      $Items | Sort-Object Index | select index, @{Name='Date';Expression={([datetime]$_.pubDate).tostring('MM/dd/yyyy')}},title,@{Name="Author";Expression={$_.creator.InnerText}},link | ft
      $Selected = Read-Host -Prompt "Type the article index you wish to display, add 'c' after the number to view content here in the console"
      If ($Selected -ilike '*c')
        $selected = $selected.trimend('c')
        $Body = @{ strURL = "$($Items | where {$_.index -eq $Selected} | select -expand link)" }
        $results = invoke-webrequest -uri '' -Body $Body -Method 'Get'
        $results.parsedhtml.getelementbyid('content').outertext | more
      else {
        Start-Process "$($Items | where {$_.index -eq $Selected } | select -expand link)"
  • #94294

    $Feed = irm
    foreach ($Item in $Feed) {
        $psObject = New-Object PSObject
        $psObject | Add-Member NoteProperty Title "$($Item.title)"
        $psObject | Add-Member NoteProperty PublicationDate "$($Item.pubDate)"
        $psObject | Add-Member NoteProperty Link "$($"
        $psObject | Add-Member NoteProperty Author "$($Item.creator.'#cdata-section')"

You must be logged in to reply to this topic.