PowerQualys.psm1

function Join-UriQuery { 
    <#
    .SYNOPSIS
    Provides ability to join two Url paths together including advanced querying
 
    .DESCRIPTION
    Provides ability to join two Url paths together including advanced querying which is useful for RestAPI/GraphApi calls
 
    .PARAMETER BaseUri
    Primary Url to merge
 
    .PARAMETER RelativeOrAbsoluteUri
    Additional path to merge with primary url (optional)
 
    .PARAMETER QueryParameter
    Parameters and their values in form of hashtable
 
    .PARAMETER EscapeUriString
    If set, will escape the url string
 
    .EXAMPLE
    Join-UriQuery -BaseUri 'https://evotec.xyz/' -RelativeOrAbsoluteUri '/wp-json/wp/v2/posts' -QueryParameter @{
        page = 1
        per_page = 20
        search = 'SearchString'
    }
 
    .EXAMPLE
    Join-UriQuery -BaseUri 'https://evotec.xyz/wp-json/wp/v2/posts' -QueryParameter @{
        page = 1
        per_page = 20
        search = 'SearchString'
    }
 
    .EXAMPLE
    Join-UriQuery -BaseUri 'https://evotec.xyz' -RelativeOrAbsoluteUri '/wp-json/wp/v2/posts'
 
    .NOTES
    General notes
    #>

    [alias('Join-UrlQuery')]
    [CmdletBinding()]
    param (
        [parameter(Mandatory)][uri] $BaseUri,
        [parameter(Mandatory = $false)][uri] $RelativeOrAbsoluteUri,
        [Parameter()][System.Collections.IDictionary] $QueryParameter,
        [alias('EscapeUrlString')][switch] $EscapeUriString
    )
    Begin {
        Add-Type -AssemblyName System.Web
    }
    Process {

        if ($BaseUri -and $RelativeOrAbsoluteUri) {
            $Url = Join-Uri -BaseUri $BaseUri -RelativeOrAbsoluteUri $RelativeOrAbsoluteUri
        }
        else {
            $Url = $BaseUri
        }

        if ($QueryParameter) {
            $Collection = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
            foreach ($key in $QueryParameter.Keys) {
                $Collection.Add($key, $QueryParameter.$key)
            }
        }

        $uriRequest = [System.UriBuilder] $Url
        if ($Collection) {
            $uriRequest.Query = $Collection.ToString()
        }
        if (-not $EscapeUriString) {
            $uriRequest.Uri.AbsoluteUri
        }
        else {
            [System.Uri]::EscapeUriString($uriRequest.Uri.AbsoluteUri)
        }
    }
}
function Join-Uri { 
    <#
    .SYNOPSIS
    Provides ability to join two Url paths together
 
    .DESCRIPTION
    Provides ability to join two Url paths together
 
    .PARAMETER BaseUri
    Primary Url to merge
 
    .PARAMETER RelativeOrAbsoluteUri
    Additional path to merge with primary url
 
    .EXAMPLE
    Join-Uri 'https://evotec.xyz/' '/wp-json/wp/v2/posts'
 
    .EXAMPLE
    Join-Uri 'https://evotec.xyz/' 'wp-json/wp/v2/posts'
 
    .EXAMPLE
    Join-Uri -BaseUri 'https://evotec.xyz/' -RelativeOrAbsoluteUri '/wp-json/wp/v2/posts'
 
    .EXAMPLE
    Join-Uri -BaseUri 'https://evotec.xyz/test/' -RelativeOrAbsoluteUri '/wp-json/wp/v2/posts'
 
    .NOTES
    General notes
    #>

    [alias('Join-Url')]
    [cmdletBinding()]
    param(
        [parameter(Mandatory)][uri] $BaseUri,
        [parameter(Mandatory)][uri] $RelativeOrAbsoluteUri
    )

    return ($BaseUri.OriginalString.TrimEnd('/') + "/" + $RelativeOrAbsoluteUri.OriginalString.TrimStart('/'))
}
function Get-QualysReportInformation {
    [CmdletBinding()]
    param(
        [int] $MaximumRecords
    )
    $Hosts = Get-QualysHostDetection -ShowIgs -QID '45027,45302,90924,91074,91328' -MaximumRecords $MaximumRecords

    $FilteredHosts = [ordered] @{}
    foreach ($Computer in $Hosts) {
        $Name = $Computer.DNS_DATA.HOSTNAME.'#cdata-section'
        $Computer.LAST_SCAN_DATETIME = [datetime]::ParseExact($Computer.LAST_SCAN_DATETIME, 'yyyy-MM-dd\THH:mm:ss\Z', $null)
        $Computer.LAST_VM_AUTH_SCANNED_DATE = [datetime]::ParseExact($Computer.LAST_VM_AUTH_SCANNED_DATE, 'yyyy-MM-dd\THH:mm:ss\Z', $null)
        $Computer.LAST_VM_SCANNED_DATE = [datetime]::ParseExact($Computer.LAST_VM_SCANNED_DATE, 'yyyy-MM-dd\THH:mm:ss\Z', $null)

        if (-not $FilteredHosts[$Name]) {
            $FilteredHosts[$Name] = $Computer
        }
        else {
            if ($Computer.LAST_SCAN_DATETIME -gt $FilteredHosts[$Name].LAST_SCAN_DATETIME) {
                $FilteredHosts[$Name] = $Computer
            }
        }
    }

    $Output = foreach ($Computer in $FilteredHosts.Values) {
        $CacheDetection = [ordered] @{}
        foreach ($Detection in $Computer.DETECTION_LIST.DETECTION) {
            $CacheDetection[$Detection.QID] = $Detection
        }

        $HostName = $Computer.DNS_DATA.HOSTNAME.'#cdata-section'
        $Domain = $Computer.DNS_DATA.DOMAIN.'#cdata-section'

        if ($CacheDetection['91074'].RESULTS.'#cdata-section') {
            $InstallationDate = $CacheDetection['91074'].RESULTS.'#cdata-section'.Replace("Microsoft Windows install date retrieved from the registry: ", "")
        }
        else {
            $InstallationDate = $null
        }
        if ($CacheDetection['91328'].RESULTS.'#cdata-section') {
            $HotFixes = ($CacheDetection['91328'].RESULTS.'#cdata-section' -replace "&apos;", "" -replace "HotfixID", "" -split "\n") | ForEach-Object { if ($_.Trim()) {
                    "KB$_" 
                } }
        }
        else {
            $HotFixes = $null
        }

        if ($CacheDetection['90924'].RESULTS.'#cdata-section') {
            $LastReboot = $CacheDetection['90924'].RESULTS.'#cdata-section'.Replace("Last Reboot Date and Time(yyyy/mm/dd hh:mm:ss): ", "")
        }
        else {
            $LastReboot = $null
        }

        if ($CacheDetection['45027'].RESULTS.'#cdata-section') {
            $Disabled = $CacheDetection['45027'].RESULTS.'#cdata-section'.Replace("Disabled User/Machine Accounts: ", "") | ForEach-Object { if ($_.Trim()) {
                    $_.Trim() -split " " 
                } }
        }
        else {
            $Disabled = $null
        }

        if ($CacheDetection['45302'].RESULTS.'#cdata-section') {
            $LocalAccountsBefore = $CacheDetection['45302'].RESULTS.'#cdata-section'
            $LocalAccounts = foreach ($Local in $LocalAccountsBefore -split "\n") {
                # Get everything before { }, and then split it on space
                $First = $Local -replace "\{.*", ""
                $First = $First -split " "
                # Get string between { }
                $Second = $Local -replace ".*\{(.*)\}.*", '$1'
                $Second = $Second -split ","

                $Name = $Second[1].Trim() -replace "Name=", ""

                $SplittedName = $Name.Split("\")
                $ObjectDomain = $SplittedName[0]
                $ObjectName = $SplittedName[1]


                $Type = $Second[0].Trim() -replace "siduse=", ""

                if ($ObjectDomain -eq $HostName) {
                    $IsLocal = $true
                    if ($Type -eq 'Group') {
                        $ObjectType = 'LocalGroup'
                    }
                    elseif ($Type -eq 'Computer') {
                        $ObjectType = 'LocalComputer'
                    }
                    elseif ($Type -eq 'User') {
                        $ObjectType = 'LocalUser'
                    }
                    else {
                        $ObjectType = $Type
                    }
                }
                else {
                    $IsLocal = $false
                    if ($Type -eq 'Group') {
                        $ObjectType = 'DomainGroup'
                    }
                    elseif ($Type -eq 'Computer') {
                        $ObjectType = 'DomainComputer'
                    }
                    elseif ($Type -eq 'User') {
                        $ObjectType = 'DomainUser'
                    }
                    else {
                        $ObjectType = $Type
                    }
                }


                [PSCustomObject] @{
                    HostName       = $HostName
                    Domain         = $Domain
                    GroupSID       = $First[0].Trim()
                    GroupName      = $First[1].Trim()
                    IsLocal        = $IsLocal
                    Type           = $ObjectType
                    ObjectDomain   = $ObjectDomain
                    ObjectName     = $ObjectName
                    ObjectFullName = $Name
                    SID            = $Second[2].Trim() -replace "SID=", ""
                }
            }
        }
        else {
            $LocalAccounts = $null
        }

        [PSCustomObject] @{
            Name             = $Computer.DNS.'#cdata-section'
            HostName         = $HostName
            Domain           = $Computer.DNS_DATA.DOMAIN.'#cdata-section'
            FQDN             = $Computer.DNS_DATA.FQDN.'#cdata-section'
            IP               = $Computer.IP
            ID               = $Computer.ID
            LAST_SCAN_DATE   = $Computer.LAST_SCAN_DATETIME
            OS               = $Computer.OS.'#cdata-section'
            TRACKING_METHOD  = $Computer.TRACKING_METHOD
            InstallationDate = $InstallationDate
            HotFixes         = $HotFixes
            LastReboot       = $LastReboot
            Disabled         = $Disabled
            LocalAccounts    = $LocalAccounts
        }
    }
    $Output
}
function Get-QualysReportLocalAdmins {
    [CmdletBinding()]
    param(
        [int] $MaximumRecords
    )
    $Hosts = Get-QualysHostDetection -ShowIgs -QID '45302' -MaximumRecords $MaximumRecords

    $FilteredHosts = [ordered] @{}
    foreach ($Computer in $Hosts) {
        $Name = $Computer.DNS_DATA.HOSTNAME.'#cdata-section'
        $Computer.LAST_SCAN_DATETIME = [datetime]::ParseExact($Computer.LAST_SCAN_DATETIME, 'yyyy-MM-dd\THH:mm:ss\Z', $null)
        $Computer.LAST_VM_AUTH_SCANNED_DATE = [datetime]::ParseExact($Computer.LAST_VM_AUTH_SCANNED_DATE, 'yyyy-MM-dd\THH:mm:ss\Z', $null)
        $Computer.LAST_VM_SCANNED_DATE = [datetime]::ParseExact($Computer.LAST_VM_SCANNED_DATE, 'yyyy-MM-dd\THH:mm:ss\Z', $null)

        if (-not $FilteredHosts[$Name]) {
            $FilteredHosts[$Name] = $Computer
        }
        else {
            if ($Computer.LAST_SCAN_DATETIME -gt $FilteredHosts[$Name].LAST_SCAN_DATETIME) {
                $FilteredHosts[$Name] = $Computer
            }
        }
    }

    $Output = foreach ($Computer in $FilteredHosts.Values) {
        $CacheDetection = [ordered] @{}
        foreach ($Detection in $Computer.DETECTION_LIST.DETECTION) {
            $CacheDetection[$Detection.QID] = $Detection
        }

        $HostName = $Computer.DNS_DATA.HOSTNAME.'#cdata-section'
        $Domain = $Computer.DNS_DATA.DOMAIN.'#cdata-section'

        # if ($CacheDetection['91074'].RESULTS.'#cdata-section') {
        # $InstallationDate = $CacheDetection['91074'].RESULTS.'#cdata-section'.Replace("Microsoft Windows install date retrieved from the registry: ", "")
        # } else {
        # $InstallationDate = $null
        # }
        # if ($CacheDetection['91328'].RESULTS.'#cdata-section') {
        # $HotFixes = ($CacheDetection['91328'].RESULTS.'#cdata-section' -replace "&apos;", "" -replace "HotfixID", "" -split "\n") | ForEach-Object { if ($_.Trim()) { "KB$_" } }
        # } else {
        # $HotFixes = $null
        # }

        # if ($CacheDetection['90924'].RESULTS.'#cdata-section') {
        # $LastReboot = $CacheDetection['90924'].RESULTS.'#cdata-section'.Replace("Last Reboot Date and Time(yyyy/mm/dd hh:mm:ss): ", "")
        # } else {
        # $LastReboot = $null
        # }

        # if ($CacheDetection['45027'].RESULTS.'#cdata-section') {
        # $Disabled = $CacheDetection['45027'].RESULTS.'#cdata-section'.Replace("Disabled User/Machine Accounts: ", "") | ForEach-Object { if ($_.Trim()) { $_.Trim() -split " " } }
        # } else {
        # $Disabled = $null
        # }

        if ($CacheDetection['45302'].RESULTS.'#cdata-section') {
            $LocalAccountsBefore = $CacheDetection['45302'].RESULTS.'#cdata-section'
            $LocalAccounts = foreach ($Local in $LocalAccountsBefore -split "\n") {
                # Get everything before { }, and then split it on space
                $First = $Local -replace "\{.*", ""
                $First = $First -split " "
                # Get string between { }
                $Second = $Local -replace ".*\{(.*)\}.*", '$1'
                $Second = $Second -split ","

                $Name = $Second[1].Trim() -replace "Name=", ""

                $SplittedName = $Name.Split("\")
                $ObjectDomain = $SplittedName[0]
                $ObjectName = $SplittedName[1]


                $Type = $Second[0].Trim() -replace "siduse=", ""

                if ($ObjectDomain -eq $HostName) {
                    $IsLocal = $true
                    if ($Type -eq 'Group') {
                        $ObjectType = 'LocalGroup'
                    }
                    elseif ($Type -eq 'Computer') {
                        $ObjectType = 'LocalComputer'
                    }
                    elseif ($Type -eq 'User') {
                        $ObjectType = 'LocalUser'
                    }
                    else {
                        $ObjectType = $Type
                    }
                }
                else {
                    $IsLocal = $false
                    if ($Type -eq 'Group') {
                        $ObjectType = 'DomainGroup'
                    }
                    elseif ($Type -eq 'Computer') {
                        $ObjectType = 'DomainComputer'
                    }
                    elseif ($Type -eq 'User') {
                        $ObjectType = 'DomainUser'
                    }
                    else {
                        $ObjectType = $Type
                    }
                }


                [PSCustomObject] @{
                    HostName       = $HostName
                    Domain         = $Domain
                    GroupSID       = $First[0].Trim()
                    GroupName      = $First[1].Trim()
                    IsLocal        = $IsLocal
                    Type           = $ObjectType
                    ObjectDomain   = $ObjectDomain
                    ObjectName     = $ObjectName
                    ObjectFullName = $Name
                    SID            = $Second[2].Trim() -replace "SID=", ""
                }
            }
            $LocalAccounts
        }

        # [PSCustomObject] @{
        # Name = $Computer.DNS.'#cdata-section'
        # HostName = $HostName
        # Domain = $Computer.DNS_DATA.DOMAIN.'#cdata-section'
        # FQDN = $Computer.DNS_DATA.FQDN.'#cdata-section'
        # IP = $Computer.IP
        # ID = $Computer.ID
        # LAST_SCAN_DATE = $Computer.LAST_SCAN_DATETIME
        # OS = $Computer.OS.'#cdata-section'
        # TRACKING_METHOD = $Computer.TRACKING_METHOD
        # InstallationDate = $InstallationDate
        # HotFixes = $HotFixes
        # LastReboot = $LastReboot
        # Disabled = $Disabled
        # LocalAccounts = $LocalAccounts
        # }
    }
    $Output
}


# $Data = foreach ($HostName in $Hosts) {
# if ($HostName.DNS_Data.HOSTNAME.'#cdata-section' -eq 'au51xvvp001') {
# $HostName
# }
# }
function Connect-Qualys {
    [CmdletBinding(DefaultParameterSetName = 'Credential')]
    param(
        [Parameter(Mandatory, ParameterSetName = 'SecurePassword')]
        [Parameter(Mandatory, ParameterSetName = 'Password')]
        [Parameter(Mandatory, ParameterSetName = 'Credential')]
        [string] $Url,
        [Parameter(Mandatory, ParameterSetName = 'SecurePassword')]
        [Parameter(Mandatory, ParameterSetName = 'Password')][string] $Username,
        [Parameter(Mandatory, ParameterSetName = 'Password')][string] $Password,
        [Parameter(Mandatory, ParameterSetName = 'Credential')][pscredential] $Credential,

        [alias('SecurePassword')][Parameter(Mandatory, ParameterSetName = 'SecurePassword')][string] $EncryptedPassword
    )

    if ($EncryptedPassword) {
        try {
            $Password = $EncryptedPassword | ConvertTo-SecureString -ErrorAction Stop
        }
        catch {
            if ($ErrorActionPreference -eq 'Stop') {
                throw
            }
            Write-Warning -Message "Connect-Qualys - Unable to convert password to secure string. Error: $($_.Exception.Message)"
            return
        }
    }
    elseif ($Credential) {
        $UserName = $Credential.UserName
        $Password = $Credential.GetNetworkCredential().Password
    }

    $Script:PowerQualys = @{
        'Uri'           = $Url
        'Authorization' = 'Basic {0}' -f ([Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $UserName, $Password))))
    }
}
function Get-QualysData {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)][ValidateSet(
            'HostSummary',
            'LocalAdmins'
        )][string] $Type,
        [int] $MaximumRecords
    )

    if ($Type -eq 'HostSummary') {
        Get-QualysReportInformation -MaximumRecords $MaximumRecords
    }
    elseif ($Type -eq 'LocalAdmins') {
        Get-QualysReportLocalAdmins -MaximumRecords $MaximumRecords
    }
    else {
        throw 'Invalid Type'
    }
}
function Get-QualysGroup {
    [CmdletBinding()]
    param(
        [int] $MaximumRecords
    )

    if (-not $Script:PowerQualys) {
        if ($ErrorActionPreference -eq 'Stop') {
            throw 'You must first connect to Qualys using Connect-Qualys'
        }
        Write-Warning -Message 'Get-QualysGroup - You must first connect to Qualys using Connect-Qualys'
        return
    }

    $invokeQualysQuerySplat = @{
        RelativeUri = 'asset/group/'
        Method      = 'GET'
        Body        = [ordered] @{
            action           = 'list'
            truncation_limit = $MaximumRecords
        }
    }

    $Query = Invoke-QualysQuery @invokeQualysQuerySplat
    if ($Query.ASSET_GROUP_LIST_OUTPUT.RESPONSE.WARNING) {
        Write-Warning -Message "Get-QualysGroup - Please be aware: $($Query.ASSET_GROUP_LIST_OUTPUT.RESPONSE.WARNING)"
    }
    $Query.ASSET_GROUP_LIST_OUTPUT.RESPONSE.ASSET_GROUP_LIST.ASSET_GROUP
}
function Get-QualysHost {
    [CmdletBinding()]
    param(
        [ValidateSet('Basic', 'Basic/AGs', 'All', 'All/AGs', 'None')][string] $Details = 'All',
        [DateTime] $ScanDateBefore,
        [DateTime] $ScanDateAfter,
        [int] $MaximumRecords,
        [switch] $Native
    )
    # https://docs.qualys.com/en/vm/api/assets/index.htm#t=host_lists%2Fhost_list.htm

    if (-not $Script:PowerQualys) {
        if ($ErrorActionPreference -eq 'Stop') {
            throw 'You must first connect to Qualys using Connect-Qualys'
        }
        Write-Warning -Message 'Get-QualysHost - You must first connect to Qualys using Connect-Qualys'
        return
    }

    $invokeQualysQuerySplat = @{
        RelativeUri = 'asset/host/'
        Method      = 'GET'
        Body        = [ordered] @{
            action           = 'list'
            details          = $Details
            truncation_limit = $MaximumRecords
        }
    }
    if ($ScanDateBefore) {
        $invokeQualysQuerySplat.Body['vm_scan_date_before'] = $ScanDateBefore.ToString('yyyy-MM-dd')
    }
    if ($ScanDateAfter) {
        $invokeQualysQuerySplat.Body['vm_scan_date_after'] = $ScanDateAfter.ToString('yyyy-MM-dd')
    }

    $Query = Invoke-QualysQuery @invokeQualysQuerySplat
    if ($Query.HOST_LIST_OUTPUT.RESPONSE.WARNING) {
        Write-Warning -Message "Get-QualysHost - Please be aware: $($Query.HOST_LIST_OUTPUT.RESPONSE.WARNING)"
    }
    if ($Query.HOST_LIST_OUTPUT.RESPONSE.HOST_LIST.HOST) {
        if (-not $Native) {
            $Properties = $Query.HOST_LIST_OUTPUT.RESPONSE.HOST_LIST.HOST[0] | Get-Member -Type Properties
            $Query.HOST_LIST_OUTPUT.RESPONSE.HOST_LIST.HOST | Select-Object -Property $Properties.Name
        }
        else {
            $Query.HOST_LIST_OUTPUT.RESPONSE.HOST_LIST.HOST
        }
    }
}
function Get-QualysHostDetection {
    [CmdletBinding()]
    param(
        [int] $MaximumRecords,
        [string] $Ids,
        [string] $IdMin,
        [string] $IdMax,
        [string] $Ip,
        [switch] $Native,
        [ValidateSet('Confirmed', 'Potential')][string] $IncludeVulnerabilityType,
        [switch] $ShowAssetId,
        [string] $OSPattern,
        [alias('Qids')][string[]] $QID,
        [string] $Severities,
        [switch] $ShowIgs
    )
    # https://docs.qualys.com/en/vm/api/assets/index.htm#t=host_lists%2Fhost_list.htm

    if (-not $Script:PowerQualys) {
        if ($ErrorActionPreference -eq 'Stop') {
            throw 'You must first connect to Qualys using Connect-Qualys'
        }
        Write-Warning -Message 'Get-QualysHostDetection - You must first connect to Qualys using Connect-Qualys'
        return
    }

    $invokeQualysQuerySplat = @{
        RelativeUri = 'asset/host/vm/detection/'
        Method      = 'GET'
        Body        = [ordered] @{
            action           = 'list'
            #details = $Details
            truncation_limit = $MaximumRecords
        }
    }
    if ($Ids) {
        $invokeQualysQuerySplat.Body['ids'] = $Ids
    }
    if ($IdMin) {
        $invokeQualysQuerySplat.Body['id_min'] = $IdMin
    }
    if ($IdMax) {
        $invokeQualysQuerySplat.Body['id_max'] = $IdMax
    }
    if ($Ip) {
        $invokeQualysQuerySplat.Body['ips'] = $Ip
    }
    if ($ScanDateBefore) {
        $invokeQualysQuerySplat.Body['vm_scan_date_before'] = $ScanDateBefore.ToString('yyyy-MM-dd')
    }
    if ($ScanDateAfter) {
        $invokeQualysQuerySplat.Body['vm_scan_date_after'] = $ScanDateAfter.ToString('yyyy-MM-dd')
    }
    if ($IncludeVulnerabilityType) {
        $invokeQualysQuerySplat.Body['include_vuln_type'] = $IncludeVulnerabilityType.ToLower()
    }
    if ($null -ne $PSBoundParameters['ShowAssetId']) {
        $invokeQualysQuerySplat.Body['show_asset_id'] = if ($ShowAssetId.IsPresent) {
            1 
        }
        else {
            0 
        }
    }
    if ($OSPattern) {
        $invokeQualysQuerySplat.Body['os_pattern'] = $OSPattern
    }
    if ($QID) {
        $invokeQualysQuerySplat.Body['qids'] = $QID -join ","
    }
    if ($Severities) {
        $invokeQualysQuerySplat.Body['severities'] = $Severities
    }
    if ($null -ne $PSBoundParameters['ShowIgs']) {
        $invokeQualysQuerySplat.Body['show_igs'] = if ($ShowIgs.IsPresent) {
            1 
        }
        else {
            0 
        }
    }

    $Query = Invoke-QualysQuery @invokeQualysQuerySplat
    if ($Query.HOST_LIST_OUTPUT.RESPONSE.WARNING) {
        Write-Warning -Message "Get-QualysHostDetection - Please be aware: $($Query.HOST_LIST_OUTPUT.RESPONSE.WARNING)"
    }
    if ($Query.HOST_LIST_VM_DETECTION_OUTPUT.RESPONSE.HOST_LIST.HOST) {
        if (-not $Native) {
            $Properties = $Query.HOST_LIST_VM_DETECTION_OUTPUT.RESPONSE.HOST_LIST.HOST[0] | Get-Member -Type Properties
            $Query.HOST_LIST_VM_DETECTION_OUTPUT.RESPONSE.HOST_LIST.HOST | Select-Object -Property $Properties.Name
        }
        else {
            $Query.HOST_LIST_VM_DETECTION_OUTPUT.RESPONSE.HOST_LIST.HOST
        }
    }
}

<#
<SIMPLE_RETURN> <RESPONSE> <DATETIME>2024-06-07T07:58:23Z</DATETIME> <CODE>1901</CODE>
 <TEXT>Unrecognized parameter(s): show_asset_ids (action=list allows: echo_request, ips, ids, id_min, id_max, ag_ids, ag_titles,
  os_pattern, truncation_limit, show_tags, show_asset_id, show_results, use_tags, no_vm_scan_since, vm_scan_since,
  vm_processed_after, vm_processed_before, vm_scan_date_before, vm_scan_date_after, vm_auth_scan_date_before,
   vm_auth_scan_date_after, compliance_enabled, include_ignored, include_disabled, show_host_services, qids,
   show_igs, show_reopened_info, host_metadata, host_metadata_fields, show_cloud_tags, cloud_tag_fields, show_qds,
   qds_min, qds_max, show_qds_factors, severities, include_search_list_titles, exclude_search_list_titles,
    include_search_list_ids, exclude_search_list_ids, output_format, max_days_since_last_vm_scan,
     max_days_since_detection_updated, detection_last_tested_since_days, detection_last_tested_before_days, status, include_vuln_type,
     active_kernels_only, arf_kernel_filter, arf_service_filter, arf_config_filter, suppress_duplicated_data_from_csv,
     detection_updated_since, detection_updated_before, detection_processed_after, detection_processed_before,
     detection_last_tested_since, detection_last_tested_before, filter_superseded_qids)</TEXT> </RESPONSE> </SIMPLE_RETURN>
#>

function Get-QualysKB {
    [CmdletBinding()]
    param(
        [string] $Ids,
        [string] $IdMin,
        [string] $IdMax,
        [string] $CVE,
        [datetime] $LastModifiedAfter,
        [datetime] $LastModifiedBefore,
        [datetime] $PublishedAfter,
        [datetime] $PublishedBefore,
        [switch] $IsPatchable
        #[ValidateSet('basic', 'all', 'none')][string] $Details
    )

    if (-not $Script:PowerQualys) {
        if ($ErrorActionPreference -eq 'Stop') {
            throw 'You must first connect to Qualys using Connect-Qualys'
        }
        Write-Warning -Message 'Get-QualysKB - You must first connect to Qualys using Connect-Qualys'
        return
    }

    $SeverityLevels = [ordered] @{
        '1' = 'Minimal'
        '2' = 'Medium'
        '3' = 'Serious'
        '4' = 'Critical'
        '5' = 'Urgent'
    }

    $invokeQualysQuerySplat = @{
        RelativeUri = 'knowledge_base/vuln/'
        Method      = 'GET'
        Body        = [ordered] @{
            action = 'list'
            # Doesn't work for some reason
            #truncation_limit = $MaximumRecords
        }
    }
    if ($Ids) {
        $invokeQualysQuerySplat.Body['ids'] = $Ids
    }
    if ($null -ne $PSBoundParameters['IsPatchable']) {
        $invokeQualysQuerySplat.Body['is_patchable'] = $IsPatchable.IsPresent
    }
    if ($IdMin) {
        $invokeQualysQuerySplat.Body['id_min'] = $IdMin
    }
    if ($IdMax) {
        $invokeQualysQuerySplat.Body['id_max'] = $IdMax
    }
    if ($CVE) {
        $invokeQualysQuerySplat.Body['cve'] = $CVE
    }
    if ($LastModifiedAfter) {
        $invokeQualysQuerySplat.Body['last_modified_after'] = $LastModifiedAfter.ToString('yyyy-MM-dd')
    }
    if ($LastModifiedBefore) {
        $invokeQualysQuerySplat.Body['last_modified_before'] = $LastModifiedBefore.ToString('yyyy-MM-dd')
    }
    if ($PublishedAfter) {
        $invokeQualysQuerySplat.Body['published_after'] = $PublishedAfter.ToString('yyyy-MM-dd')
    }
    if ($PublishedBefore) {
        $invokeQualysQuerySplat.Body['published_before'] = $PublishedBefore.ToString('yyyy-MM-dd')
    }
    # if ($Details) {
    # $Conversion = @{
    # 'basic' = 'Basic'
    # 'all' = 'All'
    # 'none' = 'None'
    # }
    # $invokeQualysQuerySplat.Body['details'] = $Conversion[$Details]
    # }
    $invokeQualysQuerySplat.Body['details'] = 'All'

    $Query = Invoke-QualysQuery @invokeQualysQuerySplat
    if ($Query.KNOWLEDGE_BASE_VULN_LIST_OUTPUT.RESPONSE.WARNING) {
        Write-Warning -Message "Get-QualysKB - Please be aware: $($Query.KNOWLEDGE_BASE_VULN_LIST_OUTPUT.RESPONSE.WARNING)"
    }
    if ($Query.KNOWLEDGE_BASE_VULN_LIST_OUTPUT.RESPONSE.VULN_LIST) {
        foreach ($Vuln in $Query.KNOWLEDGE_BASE_VULN_LIST_OUTPUT.RESPONSE.VULN_LIST.vuln) {
            $Solution = $Vuln.SOLUTION.'#cdata-section'
            if ($Solution) {
                $Solution = $Solution.Replace("\", [System.Environment]::NewLine)
            }
            $Diagnosis = $Vuln.DIAGNOSIS.'#cdata-section'
            if ($Diagnosis) {
                $Diagnosis = $Diagnosis.Replace("\", [System.Environment]::NewLine)
            }
            $Consequence = $Vuln.CONSEQUENCE.'#cdata-section'
            if ($Consequence) {
                $Consequence = $Consequence.Replace("\", [System.Environment]::NewLine)
            }
            [PSCustomObject] @{
                QID                 = $Vuln.QID                                  #45002
                Type                = $Vuln.VULN_TYPE                            #Potential Vulnerability
                Severity            = $SeverityLevels[$Vuln.SEVERITY_LEVEL]                       #2
                SeverityLevel       = $Vuln.SEVERITY_LEVEL                            #Medium
                Title               = $Vuln.TITLE.'#cdata-section'                                #TITLE
                Category            = $Vuln.CATEGORY                             #Information gathering
                #WhenChanged = $Vuln.LAST_SERVICE_MODIFICATION_DATETIME #2021-11-23T09:43:19Z
                #WhenCreated = $Vuln.PUBLISHED_DATETIME #1999-01-01T08:00:00Z
                WhenCreated         = [datetime]::ParseExact($Vuln.PUBLISHED_DATETIME, 'yyyy-MM-dd\THH:mm:ss\Z', $null)
                WhenChanged         = [datetime]::ParseExact($Vuln.LAST_SERVICE_MODIFICATION_DATETIME, 'yyyy-MM-dd\THH:mm:ss\Z', $null)
                Patchable           = if ($Vuln.PATCHABLE -eq "0") {
                    $false 
                }
                elseif ($Vuln.Patchable -eq "1") {
                    $true 
                }
                else {
                    $Vuln.PATCHABLE 
                }
                Diagnosis           = $Diagnosis
                Consequence         = $Consequence
                Solution            = $Solution
                PciFlag             = if ($Vuln.PCI_FLAG -eq "0") {
                    $false 
                }
                elseif ($Vuln.PCI_FLAG -eq "1") {
                    $true 
                }
                else {
                    $Vuln.PCI_FLAG 
                }                          #1
                ThreatIntelligence  = $Vuln.THREAT_INTELLIGENCE.Threat_Intel.'#cdata-section'                  #THREAT_INTELLIGENCE
                DiscoveryRemote     = if ($Vuln.DISCOVERY.Remote -eq "1") {
                    $true 
                }
                elseif ($Vuln.DISCOVERY.Remote -eq "0") {
                    $false 
                }
                else {
                    $Vuln.DISCOVERY.Remote 
                }
                DiscoveryAdditional = $Vuln.DISCOVERY.ADDITIONAL_INFO
                DiscoveryAuthType   = $Vuln.DISCOVERY.AUTH_TYPE_LIST.AUTH_TYPE
                #DISCOVERY = $Vuln.DISCOVERY #.'#cdata-section' #DISCOVERY
                SoftwareList        = foreach ($Software in $Vuln.SOFTWARE_LIST.SOFTWARE) {
                    [PSCustomObject] @{
                        Product = $Software.PRODUCT.'#cdata-section'
                        Vendor  = $Software.VENDOR.'#cdata-section'
                    }
                }
            }
        }
    }
    else {
        Write-Warning -Message 'Get-QualysKB - No vulnerabilities found'
    }
}

<#
action=list allows: echo_request, ids, id_min, id_max, details, is_patchable, last_modified_after,
 last_modified_before, last_modified_by_user_after, last_modified_by_user_before, last_modified_by_service_after,
  last_modified_by_service_before, code_modified_after, code_modified_before, published_after, published_before,
   discovery_method, discovery_auth_types, show_qid_change_log, show_pci_reasons, show_disabled_flag, show_supported_modules_info, cv
#>



function Invoke-QualysQuery {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)][string] $RelativeUri,
        [string] $Method = 'GET',
        [System.Collections.IDictionary] $Body = [ordred] @{},
        [ValidateSet('list', 'edit', 'reset', 'custom')][string] $Action,
        [string] $MaximumRecords
    )

    if (-not $Script:PowerQualys) {
        if ($ErrorActionPreference -eq 'Stop') {
            throw 'You must first connect to Qualys using Connect-Qualys'
        }
        Write-Warning -Message 'Invoke-QualysQuery - You must first connect to Qualys using Connect-Qualys'
        return
    }

    $Settings = @{
        Headers     = @{
            'X-Requested-With' = 'PowerQualys PowerShell Module'
            'Authorization'    = $Script:PowerQualys.Authorization
        }
        Method      = $Method
        Body        = $Body
        ErrorAction = 'Stop'
        Verbose     = $false
    }

    $joinUriQuerySplat = @{
        BaseUri               = $Script:PowerQualys.Uri + "/api/2.0/fo/"
        RelativeOrAbsoluteUri = $RelativeUri
    }
    if ($QueryParameter) {
        $joinUriQuerySplat['QueryParameter'] = $QueryParameter
    }

    $Settings['Uri'] = Join-UriQuery @joinUriQuerySplat

    if ($Action) {
        $Settings['Body']['action'] = $Action.ToLower()
    }
    if ($MaximumRecords) {
        $Settings['Body']['truncation_limit'] = $MaximumRecords
    }

    Write-Verbose -Message "Invoke-QualysQuery - Settings used: $($Settings | Out-String)"
    Write-Verbose -Message "Invoke-QualysQuery - Url queried: $($Settings['Uri'])"
    try {
        Invoke-RestMethod @Settings
    }
    catch {
        if ($ErrorActionPreference -eq 'Stop') {
            throw $_
        }
        if ($_.ErrorDetails.Message) {
            $Details = ($_.ErrorDetails.Message -split "`n" | ForEach-Object { if ($_.Trim() -ne "") {
                        $_.Trim() 
                    } } | Select-Object -Skip 1) -join " "
            Write-Warning -Message "Invoke-QualysQuery - Error when querying ($Method): $Details"
        }
        else {
            Write-Warning -Message "Invoke-QualysQuery - Error when querying ($Method): $($_.Exception.Message)"
        }
    }
}


# Export functions and aliases as required
Export-ModuleMember -Function @('Connect-Qualys', 'Get-QualysData', 'Get-QualysGroup', 'Get-QualysHost', 'Get-QualysHostDetection', 'Get-QualysKB', 'Invoke-QualysQuery') -Alias @()
# SIG # Begin signature block
# MIItsQYJKoZIhvcNAQcCoIItojCCLZ4CAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB5y61np7jWsoz1
# lUS0LoG89C5gHdTftJ/q+niYPV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