public/Get-NexposeVulnerabilityCategory.ps1
Function Get-NexposeVulnerabilityCategory { <# .SYNOPSIS Returns all vulnerabilities categories that can be assigned to a vulnerability. .DESCRIPTION Returns all vulnerabilities categories that can be assigned to a vulnerability. These categories group and label vulnerabilities by general purpose, affected systems, vendor, etc. .PARAMETER Id The identifier of the category .PARAMETER IncludeVulnerabilities Include the list of vulnerabilities contained within the selected category .EXAMPLE Get-NexposeVulnerabilityCategory -Id 123 .EXAMPLE Get-NexposeVulnerabilityCategory -Id 123 -IncludeVulnerabilities .NOTES For additional information please see my GitHub wiki page .FUNCTIONALITY GET: vulnerability_categories GET: vulnerability_categories/{id} GET: vulnerability_categories/{id}/vulnerabilities .LINK https://github.com/My-Random-Thoughts/Rapid7Nexpose #> [CmdletBinding()] Param ( [string]$Id = 0, [switch]$IncludeVulnerabilities ) If ($Id -gt 0) { $vulnCat = (Invoke-NexposeQuery -UrlFunction "vulnerability_categories/$Id" -RestMethod Get) If ($IncludeVulnerabilities.IsPresent) { $vulns = @(Invoke-NexposeQuery -UrlFunction "vulnerability_categories/$Id/vulnerabilities" -RestMethod Get) $vulnCat | Add-Member -Name 'vulnerabilities' -Value @() -MemberType NoteProperty ForEach ($vuln In $vulns) { $vulnCat.vulnerabilities += (Get-NexposeVulnerability -Id $vuln) } } Write-Output $vulnCat } Else { Write-Output @(Invoke-NexposeQuery -UrlFunction 'vulnerability_categories' -RestMethod Get) # Return All } } |