Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article details how to generate report using the RestAPI which will mirror as closely as possible the "OutputDevices" report which was available in V3 of iQSonar.
You can download the current working version of this script here, and simply customise the $user, $pass and $sonar values and it should run in your environment


Table of Contents

Fields in the original report

...

FieldV3 CommentRestAPI Comment
HostnameHostname of the deviceGet this from the /devices RestAPI endpoint 
FQDNFully QUalified Domain Name of the deviceGet this from the /devices/{Device_ID} RestAPI endpoint
OSOS description and service packGet this from the /devices/{Device_ID} RestAPI endpoint
OS Install DateOS description and service packGet this from the /devices/{Device_ID} RestAPI endpoint
May not always be available
LocationLocation of the deviceIn V4 this represents the target configuration set used to define the device.
Get this from the /devices RestAPI endpoint
Serial NumberThe serial number of the deviceGet this from the /devices RestAPI endpoint
PhysicalCPUCountNumber of physical CPUs or sockets in the Physical Device (which may differ from the Virtual or Logical host when a device is a virtual machine or partition)

IF the device is a physical device, this information is derived from the /devices/{Device_ID} RestAPI endpoint
IF the device is a virtual device AND we have scanned the virtualisation host, the information is also available.

Where the virtualisation host is not scanned, then this field and all the other information about the physical host will not be able to be populated.

PhysicalCoreCountSum of cores across all CPUs in the Physical Device (which may differ from the Virtual or Logical host when a device is a virtual machine or partition)Get this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalCoresPerCPUPhysical core count divided by the physical CPU countGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalCPUManufacturerManufacturer of the CPU on the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalCPUModelModel of the CPU on the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalCPUSpeedSpeed of the CPU on the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalRAMTotal amount of RAM on the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
VirtualCPUCountNumber of Virtual CPUs perceived by the device (only populated when the device is Virtual or Logical)Get this from the /devices/{Device_ID} RestAPI endpoint; Only available if device is virtual or logical
VirtualCoreCountSum of Cores perceived by the device (only populated when the device is Virtual or Logical)Get this from the /devices/{Device_ID} RestAPI endpoint; Only available if device is virtual or logical
VirtualRAMAmount of perceived RAM by the device (only populated when the device is Virtual or Logical)Get this from the /devices/{Device_ID} RestAPI endpoint; Only available if device is virtual or logical
DeviceModelModel of the deviceGet this from the /devices RestAPI endpoint for a physical device.
PhysicalModelSocketCountNumber of sockets that may be populated with physical CPUs on the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalModelCoreCountMaximum number of cores per CPU according to the model documentationGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalDeviceManufacturerManufacturer of the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalHostnameHostname of the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint for virtual devices; May not always be available
PhysicalFQDNFully Qualified Domain Name of the Physical DeviceGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
IP Address
  • If more than 1, will be semi-colon separated. 
  • Info such as DHCPServer from IPAddress table will not be in OutputDevices. 
  • Will only include IPv4.
V4 also exposes IP6 addresses.
PhysicalMACAddressIf more than 1, will be semi-colon separated.
VirtualMACAddressIf more than 1, will be semi-colon separated.
ClusterInformationThe virtualization cluster that the physical machine is part ofOnly available if it is part of a cluster, and the cluster has been scanned
ClusterNameName of clusterOnly available if it is part of a cluster, and the cluster has been scanned
PartitioningMethodVirtualization Method (VMware, HyperV, LPAR etc.). If this field is null it indicates the device is physical.
DerivedCPU
Not directly available via RestAPI. Must be coded in the script.
DerivedCoresPerCPU
Not directly available via RestAPI. Must be coded in the script.
BiosConcatenation of Device.BIOSName, DeviceBIOSManufacturer, Device.BIOSVersion separated by semi-colons.Get this from the /devices/{Device_ID} RestAPI endpoint.
LastScanDateLast date the device was scannedGet this from the /devices/{Device_ID} RestAPI endpoint.
DeviceIDThe unique identifier for this deviceThe Rest API gives unique identifiers in GUID format
PhysicalDeviceIDThe unique identifier of the Physical Device (where relevant) – used to map logical devices or Virtual machines back to the Physical Device which hosts them.Get this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalCPUNotesNotes that indicate CPU vs socket mismatches or CPU core values that don’t match the CPU modelThis V3 data is not directly available via RestAPI. This functionality is part of DataHub for V4, and if required must be coded in the script.
NotesNotes related to the device modelThis V3 data is not directly available via RestAPI. This functionality is part of DataHub for V4, and if required must be coded in the script.
ExternalLinkLink to model documentation from the vendorThis V3 data is not available via RestAPI.
DNSHostnameThe hostname of the device as reported from DNSGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
DNSFQDNThe fully qualified hostname of the device as reported from DNSGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalDNSHostnameThe hostname of the physical device as reported from DNSGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
PhysicalDNSFQDNThe fully qualified hostname of the physical device as reported from DNSGet this from the /devices/{Device_ID} RestAPI endpoint; May not always be available
MeasurementCommentWill contain additional info such as “Believed to be: Oracle Linux Server release 5.7” where appropriateThis V3 data is not available via RestAPI.

...

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.

Note that one limitation of using the PowerShell System.Object to build the CSV file is that the order of the colums is not fixed. An updated version of this script will address this limitation shortly.

Code Block
languagepowershell
themeMidnight
titleDefine columns for the CSV file
# 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 "OS" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "OS-Install-Date" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "Location" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "Serial-Number" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCPUCount" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCoreCount" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCoresPerCPU" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCPUManufacturer" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCPUModel" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCPUSpeed" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalRAM" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "VirtualCPUCount" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "VirtualCoreCount" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "VirtualRAM" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "DeviceModel" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalModelSocketCount" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalModelCoreCount" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalDeviceManufacturer" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalHostname" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalFQDN" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "IP-Address" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalMACAddress" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "VirtualMACAddress" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "ClusterInformation" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "ClusterName" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PartitioningMethod" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "DerivedCPU" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "DerivedCoresPerCPU" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "Bios" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "LastScanDate" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "DeviceID" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalDeviceID" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalCPUNotes" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "Notes" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "ExternalLink" -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 "PhysicalDNSHostname" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "PhysicalDNSFQDN" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "MeasurementComment" -Value $null

...