public/Get-NexposeVulnerabilityReference.ps1

Function Get-NexposeVulnerabilityReference {
<#
    .SYNOPSIS
        Returns the external references that may be associated to a vulnerability
 
    .DESCRIPTION
        Returns the external references that may be associated to a vulnerability
 
    .PARAMETER Id
        The identifier of the vulnerability
 
    .PARAMETER IncludeVulnerabilities
        Include the list of vulnerabilities contained within the selected reference
 
    .EXAMPLE
        Get-NexposeVulnerabilityReference -Id 123
 
    .NOTES
        For additional information please see my GitHub wiki page
 
    .FUNCTIONALITY
        GET: vulnerability_references
        GET: vulnerability_references/{id}
        GET: vulnerability_references/{id}/vulnerabilities
 
    .LINK
        https://github.com/My-Random-Thoughts/Rapid7Nexpose
#>


    [CmdletBinding()]
    Param (
        [string]$Id = 0,

        [switch]$IncludeVulnerabilities
    )

    If ($Id -gt 0) {
        $vulnRef = (Invoke-NexposeQuery -UrlFunction "vulnerability_references/$Id" -RestMethod Get)
        If ($IncludeVulnerabilities.IsPresent) {
            $vulns = @(Invoke-NexposeQuery -UrlFunction "vulnerability_references/$Id/vulnerabilities" -RestMethod Get)
            $vulnRef | Add-Member -Name 'vulnerabilities' -Value $vulns -MemberType NoteProperty
        }
        Write-Output $vulnRef
    }
    Else {
        Write-Output @(Invoke-NexposeQuery -UrlFunction 'vulnerability_references' -RestMethod Get)    # Return All
    }
}