Qualys
Qualys
Qualys
#$hostName = "aaaaaaaaaaa"
# Verify that the host is online by ping
break
Get-QualysVMReport
else
}
function Get-QualysVMReport {
[string]$Global:scannerName = "QuaylsScanner"
$Global:headers = @{"X-Requested-With"="powershell"}
$Global:baseUrl = "https://qualysapi.qualys.com/api/2.0/fo"
$Global:body = "action=login&username=$qualysUsername&password=$qualysPassword"
# Login and create an open session
function Get-ScanStatus {
else {
start-sleep -Seconds 30
Get-ScanStatus
Get-ScanStatus
# Launch New Report base from the Scan
function Get-ReportStatus {
$global:reportID = $latestQualysReport.id}
else {
start-sleep -Seconds 30
Get-ReportStatus
Get-ReportStatus
# Logout
TOPIC
EXAMPLES
Function Get-VMReports {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$qualysUsername,
[Parameter(Mandatory=$True,Position=2)]
[string]$qualysPassword,
[Parameter(Mandatory=$True,Position=3)]
[string]$scannerName,
[Parameter(Mandatory=$True,Position=4)]
[string]$reportType,
[Parameter(Mandatory=$True,Position=5)]
[string]$ipAddress
[Parameter(Position=6)]
[string]$vmScanProfile
[Parameter(Position=7)]
[string]$vmReportProfile
)
Begin {
CLS
}
Process{
$Global:headers = @{"X-Requested-With"="powershell"}
$Global:baseUrl = "https://qualysapi.qualys.com/api/2.0/fo"
$Global:body = "action=login&username=$qualysUsername&password=$qualysPassword"
# Login and create an open session
$vmstext = ($vms).SIMPLE_RETURN.RESPONSE.TEXT
$s = [xml]$vms.SIMPLE_RETURN.RESPONSE.ITEM_LIST.OuterXml
[string]$Global:vmScanRef = ($s.ITEM_LIST.InnerText).remove(0,19)
if ($vmstext -like "*launched*"){
Write-Host "The New VM Scan did not start becuase of " + $vmstext
Break
}
# Check to see if Scan Complete based on scan title.
function Get-ScanStatus {
if ($latestVMQualysScan.SCAN_LIST_OUTPUT.RESPONSE.SCAN_LIST.scan.STATUS.STATE -like
"*Finished*"){
else {
start-sleep -Seconds 40
Get-ScanStatus
Get-ScanStatus
# Launch New Report base from the Scan
$vmrtext = ($vmr).SIMPLE_RETURN.RESPONSE.TEXT
$r = [xml]$vmr.SIMPLE_RETURN.RESPONSE.ITEM_LIST.OuterXml
[string]$Global:vmReportRef = ($s.ITEM_LIST.InnerText).remove(0,19)
if ($vmrtext -like "*launched*"){
else {
Write-Host "The New VM Report did not start becuase of " + $vmrtext
Break
}
# Check to see if Report Complete
function Get-ReportStatus {
$global:reportID = $latestQualysReport.id}
else {
start-sleep -Seconds 10
write-host "Report still Running"
Get-ReportStatus
}
Get-ReportStatus
}
End {
# Logout
}
}