Samples/ImportCallhomeDetails/lxco/GetDevicesFromLXCO.ps1

# ------------------------------------------------------------------
# Lenovo Copyright
#
# (C) Copyright Lenovo 2024 - present.
#
# LIMITED AND RESTRICTED RIGHTS NOTICE:
# If data or software is delivered pursuant a General Services
# Administration (GSA) contract, use, reproduction, or disclosure
# is subject to restrictions set forth in Contract No. GS-35F-05925.
# ------------------------------------------------------------------

Import-Module LXCOPSTool

function GetLXCODevices()
{
    param (
        [Parameter(Mandatory = $true)] $Connection,
        [Parameter(Mandatory = $true)] [hashtable] $Devices
    )

    $lxcoDevices = Get-LXCODevices -Connection $Connection -DeviceType Server
    $managedDevices = 0
    foreach($dev in $lxcoDevices)
    {
        if ($Devices.ContainsKey($dev.SerialNumber))
        {
            $Devices[$dev.SerialNumber].isManaged = $true
            $Devices[$dev.SerialNumber].id = $dev.Id
            $Devices[$dev.SerialNumber].groups = $dev.Groups
            $managedDevices ++
        }
    }
    Write-Host "Manged devices: $managedDevices"
    $addressesNeeded = @()
    foreach($dev in $Devices.GetEnumerator())
    {
        if ($true -eq $dev.Value.isManaged)
        {
            if (-not ($addressesNeeded -contains $dev.Value.addressHash))
            {
                $addressesNeeded += $dev.Value.addressHash
            }
        }
    }
    return $addressesNeeded
}

# EOF