This is the second in a series of articles giving extended example of how to use the RestAPI. This article will demonstrate how to generate a report equivalent to the Version 3 "OutputApplications" view using PowerShell. For a shorter example that returns a simpler dataset, you can see the article Use RestAPI and PHP to generate a list of Applications.
You can download the latest version of the file: OutputApplications-v1.ps1, and simply customise the $user, $pass and $sonar values and it should run in your environment
Table of Contents |
---|
Fields in the original report
...
Build the CSV file header row
PowerShell has a number of built in libraries for handling output to various file formats. For this example we will be saving the results in a CSV file that can be viewed directly in EXCEL or imported into other databases.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# Build the CSV File header row $csv = @() $row = New-Object System.Object $row | Add-Member -MemberType NoteProperty -Name "Hostname" -Value $null $row | Add-Member -MemberType NoteProperty -Name "FQDN" -Value $null $row | Add-Member -MemberType NoteProperty -Name "SoftwareName" -Value $null $row | Add-Member -MemberType NoteProperty -Name "SoftwareVersion" -Value $null $row | Add-Member -MemberType NoteProperty -Name "SoftwareVendor" -Value $null $row | Add-Member -MemberType NoteProperty -Name "SoftwareEdition" -Value $null $row | Add-Member -MemberType NoteProperty -Name "InstanceIdentifier" -Value $null $row | Add-Member -MemberType NoteProperty -Name "ClusterInformation" -Value $null $row | Add-Member -MemberType NoteProperty -Name "UserCount" -Value $null $row | Add-Member -MemberType NoteProperty -Name "LastScanDate" -Value $null $row | Add-Member -MemberType NoteProperty -Name "Location" -Value $null $row | Add-Member -MemberType NoteProperty -Name "Language" -Value $null $row | Add-Member -MemberType NoteProperty -Name "ApplicationID" -Value $null $row | Add-Member -MemberType NoteProperty -Name "DeviceID" -Value $null $row | Add-Member -MemberType NoteProperty -Name "DNSHostname" -Value $null $row | Add-Member -MemberType NoteProperty -Name "DNSFQDN" -Value $null $row | Add-Member -MemberType NoteProperty -Name "Evidence" -Value $null |
...
- A VMWare cluster reports ESX Nodes and ESX Clusters as distinct entries in the Applications output.
- ESX Node has "product.name" set to "VMware VSphere Hypervisor", In this case we don't populate the "clusterinformation" column.
The parent_cluster information (if present) points to the cluster this node is part of. - ESX Cluster entry has "type" set to "VMWare Cluster", no edition, "name" is name of cluster
Links to cluster nodes, link to cluster parent (self), node id given, need to generate and follow link to device ID for node names
- ESX Node has "product.name" set to "VMware VSphere Hypervisor", In this case we don't populate the "clusterinformation" column.
- Veritas Cluster Server,
Links to clusters gives list of nodes, same as in devices. node names in devices. - Windows Server Cluster
Links to two or more devices
No "cluster" or "parent_cluster" entry - Oracle Database Cluster Server
Multiple devices
No "clusters" or "parent_cluster" entry - SQL Server Cluster
No cluster info available - Websphere AS Cluster
Multiple devices
No "clusters" or "parent_cluster" entry
...