Created
February 1, 2018 22:32
-
-
Save wpietrzakpl/bc54b17df5bd54610c30c50fcff485b8 to your computer and use it in GitHub Desktop.
Iron-Scripter_v3.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Iron Scripter v3 | |
.DESCRIPTION | |
https://cdn-powershell.pressidium.com/wp-content/uploads/2018/01/Iron-Scripter-Prequel-Puzzle-3.pdf | |
.EXAMPLE | |
PS C:\Users\Wojtek\Documents\WindowsPowerShell> .\Iron-Scripter_3.ps1 | |
0 - Help us Recognize Amazing PowerShell Contributors! | |
1 - Distilling Microsoft's DSC Update (Jan 2018) | |
2 - PowerShell Story Continued Becoming a Craftsman | |
3 - Iron Scripter Prequel: Puzzle 2 - a commentary | |
4 - Iron Scripter 2018 Prequel: Puzzle 3 | |
5 - Summit 2018 registration update | |
6 - PowerShell Summit Registration Status | |
7 - Iron Scripter Prequel: Puzzle 1 - a solution | |
8 - Iron Scripter 2018 Prequel: Puzzle 2 | |
9 - Can We Talk About PowerShell Core 6.0? | |
Choose article!: 2 | |
Title : PowerShell Story Continued Becoming a Craftsman | |
Publication Date : Sun, 28 Jan 2018 10:46:03 +0000 | |
Link : https://powershell.org/2018/01/28/powershell-story-continued-becoming-a-craftsman/ | |
Author : creator | |
How do you want to read article? | |
1 - Web | |
2 - ConsoleView | |
Choose option!: 2 | |
.INPUTS | |
Inputs (if any) | |
.OUTPUTS | |
Output (if any) | |
.NOTES | |
Wojtek o2|2o18 | |
#> | |
[CmdletBinding()] | |
param ( | |
) | |
begin { | |
[string]$Uri = 'https://powershell.org/feed' | |
[int]$incrementation = 0 | |
} | |
process { | |
$feed = Invoke-RestMethod -Uri $Uri | |
$articleCounter = @() | |
$feed | ForEach-Object { | |
Write-Host $incrementation "-" $_.Title -ForegroundColor Green | |
$incrementation++ | |
$articleCounter += $incrementation | |
} | |
$article = Read-Host -Prompt "Choose article!" | |
$articleObject = [PSCustomObject]@{ | |
Title = $feed.Title[$article] | |
"Publication Date" = $feed.pubDate[$article] | |
Link = $feed.link[$article] | |
Author = $feed.creator[$article] | |
} | |
$articleObject | Format-List | |
Write-Host "How do you want to read article?" -ForegroundColor Green | |
Write-Host "1 - Web " -ForegroundColor Green | |
Write-Host "2 - ConsoleView" -ForegroundColor Green | |
try { | |
[ValidatePattern("[1]|[2]")][int]$view = Read-Host -Prompt "Choose option!" -ErrorAction Stop | |
} | |
catch { | |
Write-Host "Error, choose again" -ForegroundColor Red | |
} | |
switch ($view) { | |
1 { | |
$articleLink = $feed.link[$article] | |
$ie = New-Object -ComObject internetexplorer.application | |
$ie.navigate2($articleLink) | |
$ie.visible = $true | |
} | |
2 { | |
$ConsoleView = Invoke-WebRequest -Uri $articleObject.link | |
($ConsoleView.parsedHTML.getelementsbytagname('div') | Where-Object { $_.className -eq 'entry-content' }).innerText | |
} | |
Default {"You choose nothing!"} | |
} | |
} | |
end { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment