lazywinadmin / CountriesPS

CountriesPS is a module to retrieve data about Countries using the https://restcountries.eu/ REST API
MIT License
9 stars 2 forks source link

Get-Country generates a WriteErrorException exception #1

Closed doctordns closed 2 years ago

doctordns commented 2 years ago

HI - I love ths module - and use it in my PowerShell books. Sadly, the cmdlet now fails as follows:

PS C:\Foo\dl\CountriesPS\1.0.0.0> ls
    Directory: C:\Foo\dl\CountriesPS\1.0.0.0
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          23/04/2022    08:42                Public
-a---          20/11/2016    22:39           8496 CountriesPS.psd1
-a---          20/11/2016    22:39           1058 CountriesPS.psm1

PS C:\Foo\dl\CountriesPS\1.0.0.0> Import-Module .\CountriesPS.psd1
PS C:\Foo\dl\CountriesPS\1.0.0.0> Get-Module CountriesPS

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     1.0.0.0               CountriesPS                         Get-Country

PS C:\Foo\dl\CountriesPS\1.0.0.0> get-country 'gb'
Get-Country: A positional parameter cannot be found that accepts argument 'gb'.
PS C:\Foo\dl\CountriesPS\1.0.0.0> get-country -name gb
Get-Country: Exception of type 'Microsoft.PowerShell.Commands.WriteErrorException' was thrown.
PS C:\Foo\dl\CountriesPS\1.0.0.0> get-error

Exception             :
    Type    : Microsoft.PowerShell.Commands.WriteErrorException
    Message : Exception of type 'Microsoft.PowerShell.Commands.WriteErrorException' was thrown.
    HResult : -2146233087
CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-Country
InvocationInfo        :
    MyCommand        : Get-Country
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 52
    Line             : get-country -name gb
    PositionMessage  : At line:1 char:1
                       + get-country -name gb
                       + ~~~~~~~~~~~~~~~~~~~~
    InvocationName   : get-country
    CommandOrigin    : Internal
ScriptStackTrace      : at Get-Country<Process>, C:\Foo\dl\CountriesPS\1.0.0.0\Public\Get-Country.ps1: line 491
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
lazywinadmin commented 2 years ago

Thanks for reporting this @doctordns Seems the api changed, will take a look tomorrow

lazywinadmin commented 2 years ago

Fixed. Module is now using restcountries.com instead of restcountries.eu. New version published on PowerShell Gallery. Thanks again for flagging this @doctordns

doctordns commented 2 years ago

Thanks - it is a nice module!