Get-vRAContentData fails on PowerShell Core #97

Closed
jonathanmedd opened this Issue Jan 5, 2017 · 7 comments

Projects

None yet

2 participants

@jonathanmedd
Contributor

$ContentData = Get-vRAContent -Id $TestContent.Id | Get-vRAContentData

Invoke-RestMethod : Unexpected character encountered while parsing value: i. Path '', line 0, position 0.
At /Users/jon_medd/.local/share/powershell/Modules/PowervRA/Functions/Public/Invoke-vRARestMethod.ps1:125 char:21

  •     $Response = Invoke-RestMethod @Params
    
  •                 ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Invoke-RestMethod], JsonReaderException
    • FullyQualifiedErrorId : Newtonsoft.Json.JsonReaderException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
@jonathanmedd jonathanmedd added the bug label Jan 5, 2017
@chelnak chelnak was assigned by jonathanmedd Jan 5, 2017
@chelnak
Contributor
chelnak commented Jan 6, 2017

Just as we thought:

image

You can see it's ignoring the content type of the response.. also found this issue which confirms the issue:

PowerShell/PowerShell#2245

@chelnak
Contributor
chelnak commented Jan 6, 2017

A quick test with Invoke-WebRequest seems to be successful...

 (Invoke-WebRequest -Uri  https://httpbin.org/robots.txt).content
@chelnak
Contributor
chelnak commented Jan 6, 2017

I've implemented a check to fail this function if it is executed in Core:

        if ($PSVersionTable.PSEdition -eq "core") {

            throw "This function does not support PowerShell Core Edition"

        }

Have tested in 4.0, 5.1 + 6 alpha 14 and results appear to be as expected.

I noticed that Nick Bradford (PowerNSX) had also commented on the same issue back in November. It appears that he has a work around but in my opinion it is too complicated to implement just for the benefit of one function. If the user want's to view data they can create a package and export it to see the content.

What are your views @jonathanmedd ?

@chelnak chelnak added a commit that referenced this issue Jan 6, 2017
@chelnak chelnak Implements workaround for issue #97 285037f
@jonathanmedd
Contributor

Good job! Yes, completely agree with the solution for now. I think maybe we just leave this issue open as a reminder to track the PowerShell bug and hopefully can remove this change at some point?

@chelnak
Contributor
chelnak commented Jan 7, 2017

Sounds good!

@jonathanmedd jonathanmedd added a commit that referenced this issue Feb 8, 2017
@jonathanmedd jonathanmedd Removing this check, since the issue preventing this working has been…
… resolved in PS Alpha 15. Fixes issue #97
8132379
@jonathanmedd
Contributor

The issue preventing this from working has been resolved in PowerShell Alpha 15 - PowerShell/PowerShell#2245. I have tested this and all is now good for Get-vRAContentData

@jonathanmedd
Contributor

We will of course have to raise the support level for PowervRA in the next release to be PowerShell Alpha 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment