1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | function Get -BibleVerse { < # .SYNOPSIS Calls the bible.org api and returns the specified scriptures. .DESCRIPTION Calls the bible.org api to return the specified book -chapter -verse , random verse, or verse of the day. .PARAMETER Random Indicates the scripture returned should be random. .PARAMETER VerseOfTheDay Indicates the scripture returned should be the verse of the day. .PARAMETER Book Indicates the book to return, such as Matthew, Marke, Luke, or John. .EXAMPLE PS C:\> Get -BibleVerse -Random .EXAMPLE PS C:\> Get -BibleVerse -VerseOfTheDay -Type Json -Formatting Plain .EXAMPLE PS C:\> Get -BibleVerse -Book Ephesians -Chapter 5 -Verse 25 -Type Json .NOTES Michael West 07.23.2013 .LINK #> [CmdletBinding(DefaultParameterSetName= "Default" )] param( [Parameter(ParameterSetName= "Random" )] [switch] $Random , [Parameter(ParameterSetName= "Votd" )] [switch] $VerseOfTheDay , [Parameter(ParameterSetName= "Default" )] [ValidateNotNullOrEmpty()] [string] $Book = "Genesis" , [Parameter(ParameterSetName= "Default" )] [ValidateScript({$_ -gt 0})] [int] $Chapter = 1, [Parameter(ParameterSetName= "Default" )] [ValidateScript({$_ -gt -1})] [int] $Verse =1, [ValidateSet( "Json" , "Xml" , "Text" )] [string] $Type = "Text" , [ValidateSet( "Full" , "Para" , "Plain" )] [string] $Formatting = "Plain" ) if( $PSCmdlet .ParameterSetName -eq "Votd" ) { $url += "votd" } elseif ( $PSCmdlet .ParameterSetName -eq "Random" ) { $url += "random" } else { $url += "$($Book)+$($Chapter)" if( $Verse ) { $url += ":$($Verse)" } } $url += "&type=$($Type)&formatting=$($Formatting)" $url = $url .ToLower() $result = Invoke -WebRequest -Uri $url if( $result ) { $result .Content } } |
1 2 | $scripture = (Get -BibleVerse -VerseOfTheDay -Type Json | ConvertFrom -Json )[0] "$($scripture.bookname) $($scripture.chapter):$($scripture.verse) $($scripture.text)" |
No comments:
Post a Comment