Skip to content

Instantly share code, notes, and snippets.

@MSAdministrator
Created November 12, 2015 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MSAdministrator/a8fa329c9d22508b5b20 to your computer and use it in GitHub Desktop.
Save MSAdministrator/a8fa329c9d22508b5b20 to your computer and use it in GitHub Desktop.
Get-QualysAssetGroupInformation
#requires -Version 3
<#
.Synopsis
This function gets Business Unit information
.DESCRIPTION
This function is primarily called from the Get-NofiticationData function to gather busines unit information.
Once we have this information it used to begin processing notification emails
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
.INPUTS
Inputs to this cmdlet (if any)
.OUTPUTS
Output from this cmdlet (if any)
.NOTES
General notes
.COMPONENT
The component this cmdlet belongs to
.ROLE
The role this cmdlet belongs to
.FUNCTIONALITY
The functionality that best describes this cmdlet
#>
function Get-QualysAssetGroupInformation
{
[CmdletBinding(DefaultParameterSetName = 'Parameter Set 1',
SupportsShouldProcess = $true,
PositionalBinding = $false,
HelpUri = 'http://www.microsoft.com/',
ConfirmImpact = 'Medium')]
[Alias()]
[OutputType([String])]
Param
(
# Param1 help description
[parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = 'Please provide a crednetial obejct')]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.CredentialAttribute()]$credential
)
Begin
{
$results = @()
$assetGroupInfo = @()
[xml]$assetGroupInfo = Invoke-RestMethod -Uri 'https://qualysapi.qualys.com/msp/asset_group_list.php' -Credential $credential
}
Process
{
foreach ($item in $assetGroupInfo.SelectNodes('/ASSET_GROUP_LIST/ASSET_GROUP'))
{
for ($u = 0; $u -lt $($item.ASSIGNED_USERS.ASSIGNED_USER.LOGIN).count;$u++)
{
if ($item.ASSIGNED_USERS.ASSIGNED_USER[$u].ROLE.InnerText -eq 'Unit Manager')
{
$tempAssetGroupInfo = @()
$props = @{
userlogin = $($item.ASSIGNED_USERS.ASSIGNED_USER[$u].LOGIN.InnerText)
userrole = $($item.ASSIGNED_USERS.ASSIGNED_USER[$u].ROLE.InnerText)
assetgrouptitle = $($item.TITLE.InnerText)
ip = $($item.SCANIPS.IP)
}
$tempAssetGroupInfo = New-Object -TypeName PSObject -Property $props
$results += $tempAssetGroupInfo
}
}
}
}
End
{
Export-Clixml -Path C:\POSH-Guard\_supporting_data\assetgroupinfo.xml -InputObject $results
return $results
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment