New-QotD.ps1
something exciting
Some information about the exciting thing
Table of contents generated with markdown-toc
Script
<#
.SYNOPSIS
.DESCRIPTION
.EXAMPLE
.INPUTS
.OUTPUTS
.NOTES
Author: Luke Leigh
Website: https://blog.lukeleigh.com/
LinkedIn: https://www.linkedin.com/in/lukeleigh/
GitHub: https://github.com/BanterBoy/
GitHubGist: https://gist.github.com/BanterBoy
.LINK
#>
function New-QotD {
[CmdletBinding()]
$Uri = @{
"QuoteOfTheDay" = "http://quotes.rest/qod"
}
$QuoteOfTheDay = Invoke-RestMethod -Method GET -Uri $Uri.QuoteOfTheDay -Headers @{
'Content-Type' = 'application/json'
}
foreach ( $item in $QuoteOfTheDay ) {
try {
$QuoteOfTheDayProperties = $item | Select-Object -Property *
$QuoteOfTheDayProperties = @{
Quote = $QuoteOfTheDayProperties.contents.quotes.quote
Length = $QuoteOfTheDayProperties.contents.quotes.length
Author = $QuoteOfTheDayProperties.contents.quotes.author
Tags = $QuoteOfTheDayProperties.contents.quotes.tags
Category = $QuoteOfTheDayProperties.contents.quotes.category
Date = $QuoteOfTheDayProperties.contents.quotes.date
Permalink = $QuoteOfTheDayProperties.contents.quotes.permalink
Title = $QuoteOfTheDayProperties.contents.quotes.title
Background = $QuoteOfTheDayProperties.contents.quotes.background
Id = $QuoteOfTheDayProperties.contents.quotes.id
}
}
catch {
$QuoteOfTheDayProperties = @{
Quote = $QuoteOfTheDayProperties.contents.quotes.quote
Length = $QuoteOfTheDayProperties.contents.quotes.length
Author = $QuoteOfTheDayProperties.contents.quotes.author
Tags = $QuoteOfTheDayProperties.contents.quotes.tags
Category = $QuoteOfTheDayProperties.contents.quotes.category
Date = $QuoteOfTheDayProperties.contents.quotes.date
Permalink = $QuoteOfTheDayProperties.contents.quotes.permalink
Title = $QuoteOfTheDayProperties.contents.quotes.title
Background = $QuoteOfTheDayProperties.contents.quotes.background
Id = $QuoteOfTheDayProperties.contents.quotes.id
}
}
finally {
$obj = New-Object -TypeName PSObject -Property $QuoteOfTheDayProperties
Write-Output $obj
}
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.