microsoft / MSRC-Microsoft-Security-Updates-API

Repo with getting started projects for the Microsoft Security Updates API (msrc.microsoft.com/update-guide)
https://msrc.microsoft.com/update-guide
MIT License
366 stars 117 forks source link

Get-MsrcCvrfDocument : Cannot retrieve the dynamic parameters for the cmdlet. #9

Open vrdse opened 7 years ago

vrdse commented 7 years ago

On Windows 7 with PowerShell 3 I get the following error:

Get-MsrcCvrfDocument "2016-Aug" -Verbose

Get-MsrcCvrfDocument : Cannot retrieve the dynamic parameters for the cmdlet. Unable to get online the list of CVRF ID

Presumably that is because Invoke-RestMethod doesn't accept the "Accept" header.

Invoke-RestMethod -Uri 'https://api.msrc.microsoft.com/Updates?api-Version=2016-08-01' -Headers @{ 'Api-Key' = 'x' 'Accept' = 'application/json' }

Invoke-RestMethod : The 'Accept' header must be modified using the appropriate property or method. Parameter name: name

Edit: On Windows 2012 R2 with PowerShell 5.0 i get the same error for Get-MsrcCvrfDocument but Invoke-RestMethod is working. Please note that I'm behind a proxy and set the proxy configuration as $PSDefaultParameterValues (see #5 ). Might also be related to that.

Xeleema commented 7 years ago

I am experiencing the same issue in 1.6.6. However, when Get-CVRFID is sourced and ran directly, it works (this confirms the problem in Get-MsrcCvrfDocument, however despite my efforts I am unable to narrow-down exactly what Get-MsrcCvrfDocument is doing wrong before it calls Get-CVRFID).

Reproduction steps below, along w/ error analysis and information on my platform.

PS C:\>
PS C:\>
PS C:\> ##
PS C:\> ## TEST BLOCK (Base) - C:\CVRF\MsrcSecurityUpdates
PS C:\> ##
PS C:\>
PS C:\> $error.clear()
PS C:\>
PS C:\> $PSDefaultParameterValues += @{'*:ProxyUseDefaultCredentials'=$true;'*:Proxy'='http://MY_PROXY.DOMAIN.com:PORT/'} ## redacted from comment
PS C:\>
PS C:\> Import-Module C:\CVRF\MsrcSecurityUpdates
PS C:\>
PS C:\> $MyAPIKey = "MY_API_KEY" ## redacted from comment
PS C:\> Set-MSRCApiKey -ApiKey $MyAPIKey
PS C:\>
PS C:\> Get-MsrcCvrfDocument -ID "2017-May" -Verbose
Get-MsrcCvrfDocument : Cannot retrieve the dynamic parameters for the cmdlet. Unable to get online the list of CVRF ID
At line:1 char:1
+ Get-MsrcCvrfDocument -ID "2017-May" -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-MsrcCvrfDocument], ParameterBindingException
    + FullyQualifiedErrorId : GetDynamicParametersException,Get-MsrcCvrfDocument
PS C:\>
PS C:\> ##
PS C:\> ## TEST BLOCK (end)
PS C:\> ##
PS C:\>

Error review;

PS C:\> $error[0]
Get-MsrcCvrfDocument : Cannot retrieve the dynamic parameters for the cmdlet. Unable to get online the list of CVRF ID
At line:1 char:1
+ Get-MsrcCvrfDocument -ID "2017-May" -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-MsrcCvrfDocument], ParameterBindingException
    + FullyQualifiedErrorId : GetDynamicParametersException,Get-MsrcCvrfDocument

PS C:\>

PS C:\>
PS C:\> $error[1]
Unable to get online the list of CVRF ID
At C:\CVRF\MsrcSecurityUpdates\Public\Get-MsrcCvrfDocument.ps1:54 char:13
+             Throw 'Unable to get online the list of CVRF ID'
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Unable to get online the list of CVRF ID:String) [], RuntimeException
    + FullyQualifiedErrorId : Unable to get online the list of CVRF ID

PS C:\>

PS C:\> $Error[2]
Invoke-RestMethod :

Access Denied (authentication_failed)
##
## redacted full error from proxy text.
##
At C:\CVRF\MsrcSecurityUpdates\Private\Get-CVRFID.ps1:46 char:15
+             ((Invoke-RestMethod @RestMethod).Value).ID
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
PS C:\>

FYI: Platform is Windows Server 2012 R2 (w/ "Update 1" and all other security-related patches applied).

PS C:\> $PSversionTable
Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34014
BuildVersion                   6.3.9600.17400
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

NOTE: When I source Private\Get-CVRFID.PS1 and run it manually (done from the same PowerShell session that the test-block above was executed in), it works just fine;

PS C:\> ##
PS C:\> ## Failure Testing
PS C:\> ##
PS C:\>
PS C:\> . C:\CVRF\MsrcSecurityUpdates\Private\Get-CVRFID.ps1
PS C:\> Get-CVRFID -ID "2017-May"

ID                 : 2017-May
Alias              : 2017-May
DocumentTitle      : May 2017 Security Updates
Severity           :
InitialReleaseDate : 2017-05-09T07:00:00Z
CurrentReleaseDate : 2017-05-09T07:00:00Z
CvrfUrl            : https://api.msrc.microsoft.com/cvrf/2017-May?api-Version=2016-08-01

PS C:\>
PS C:\> ##
PS C:\> ## Failure Testing (end)
PS C:\> ##
Xeleema commented 7 years ago

To clarify, my organization is still unable to utilize the API. This is a concern, since the BulletinSearch.xlsx has not been updated since March (we use that resource to get the patch 'Title' names. See Issue #2 )

EnviableOne commented 7 years ago

Issue still persists in 1.7.2 with PS 5.0.1

Get-MsrcCvrfDocument : Cannot retrieve the dynamic parameters for the cmdlet. Unable to get online the list of CVRF ID At C:\msrc\GetMSRC.ps1:8 char:1