Public/Get-ModernDomainScanReport.ps1
# Get-ModernDomainScanReport # https://dss.globalcyberalliance.org/api/v1/docs#tag/version # curl https://dss.globalcyberalliance.org/api/v1/scan/example.com function Get-ModernDomainScanReport { <# .SYNOPSIS Retrieves and optionally displays a domain security scan report from Global Cyber Alliance. .PARAMETER Domain The domain name to scan (e.g., example.com). .PARAMETER Raw If specified, returns the raw 'advice' object instead of formatted output. .EXAMPLE Get-ModernDomainScanReport -Domain "contoso.com" .EXAMPLE Get-ModernDomainScanReport -Domain "contoso.com" -Raw #> param ( [Parameter(Mandatory = $true)] [string]$Domain, #= "globalcyberalliance.org" [switch]$Raw ) $url = "https://dss.globalcyberalliance.org/api/v1/scan/$Domain" try { $response = Invoke-RestMethod -Uri $url -Method Get -ErrorAction Stop #$response | fl * #$response.advice | ConvertFrom-Json If($Raw) { #return $response return $response.advice } else { #Write-Host "`n--- Advice Section ---`n" Write-Output "`n=== Advice Section ===`n" #-ForegroundColor Cyan foreach ($key in $response.advice.PSObject.Properties.Name) { #Write-Host "$key:`n$($response.advice.$key -join "`n")`n" #Write-Host "${key}:`n$($response.advice.$key -join "`n")`n" $value = $response.advice.$key if ($value -is [System.Collections.IEnumerable] -and -not ($value -is [string])) { #Write-Host "$key:`n$($value -join "`n")`n" Write-Output "${key}:`n$($value -join "`n")`n" } else { #Write-Host "$key: $value`n" Write-Output "${key}: $value`n" } } #Write-Host "`n--- Scan Result Section ---`n" Write-Output "`n=== Scan Result Section ===`n" #-ForegroundColor Cyan foreach ($key in $response.scanResult.PSObject.Properties.Name) { $value = $response.scanResult.$key if ($value -is [System.Collections.IEnumerable] -and -not ($value -is [string])) { #Write-Host "$key:`n$($value -join "`n")`n" Write-Output "${key}:`n$($value -join "`n")`n" } else { #Write-Host "$key: $value`n" Write-Output "${key}: $value`n" } } } } catch { Write-Error "Failed to retrieve scan report: $_" } } #Get-ModernDomainScanReport -Domain "example.com" #Get-ModernDomainScanReport -Domain "globalcyberalliance.org" -Raw #Get-ModernDomainScanReport -Domain "globalcyberalliance.org" #Get-ModernDomainScanReport -Domain "contoso.com" |