IGELPSIGELUMS

Import Devices with Name

Import Devices - IGEL Serial Number Format

Say, you received an order of 50+ IGEL devices and your procurement department just finished creating assets and inventory numbers for each of them.
The next step would be to import them in your UMS – and since you requested an import file in a serial number format:

;14D3F5001B1824036B;00E0C52357EC;;
;14D3F5001B18240392;00E0C5235813;;
;14D3F5001B18240419;00E0C523589A;;
;14D3F5001B1824043C;00E0C52358BD;;

you can just do that with the existing function within the UMS:

Import IGEL serial number format

By default, all imported devices are named the prefix “TC-” and the UnitID of the device (f.i. “TC-00E0C5235813”).
If you want to address your own naming convention you will not find help out of the box.

One way a lot of companies want to do, is to name their devices incorporating a prefix and asset information. Here your procurement department will be able to provide you a list, containing the serialnumber and said asset information, e.g. inventory number:

InventoryNumber;SerialNumber
2782;14D3F5001B1824036B
2784;14D3F5001B18240419
2785;14D3F5001B1824043F

Given both datasets we are now able to to merge both datasets and use the API with my Powershell module PSIGEL to create new devices and use the naming convention DEV-InventoryNumber.

I start by setting default parameters for authorization and UMS-server:

$PSDefaultParameterValues = @{
  '*-UMS*:Computername'          = 'igelrmserver'
  'New-UMSAPICookie:Credential' = (Get-Credential)
}
$PSDefaultParameterValues += @{
  '*-UMS*:WebSession' = New-UMSAPICookie
}

Then I define the path to both the IGEL serialnumber format and the asset file and import them into objects:

$Path = 'C:\Temp\'
$IGELImportFile = '{0}2260123456-000010.csv' -f $Path
$AssetExportFile = '{0}Assets.csv' -f $Path

$IGELImportColl = Import-Csv -Delimiter ';' -Path $IGELImportFile -Header '0', 'SerialNumber', 'MacAddress', '3', '4'
$AssetExportColl = Import-Csv -Delimiter ';' -Path $AssetExportFile

I provide the prefix and the major version number for the new devices:

$DevicePrefix = 'DEV-'
$MajorVersion = 10

Now I determine the ID of the latest firmware version for the aforementioned major version:

$FirmwareId = (((Get-UMSFirmware).where{ $_.Version.Major -eq $MajorVersion } |
      Sort-Object -Property Version -Descending)[0]).Id

In the next step I use the Join-Object function from Warren Frame to join both dataset objects I imported at the beginning:

$NewDeviceCollParams = @{
  Left              = $IGELImportColl
  LeftJoinProperty  = 'SerialNumber'
  LeftProperties    = 'SerialNumber', 'MacAddress'
  Right             = $AssetExportColl
  RightJoinProperty = 'SerialNumber'
  RightProperties   = 'InventoryNumber'
  Type              = 'AllInLeft'
}
$NewDeviceColl = Join-Object @NewDeviceCollParams

In the last step I create a new device from each item of the resulting object:

foreach ($NewDevice in $NewDeviceColl)
{
  $NewDeviceParams = @{
    Mac          = $NewDevice.MacAddress
    FirmwareId   = $FirmwareId
    Name         = '{0}{1}' -f $DevicePrefix, $NewDevice.InventoryNumber
    SerialNumber = $NewDevice.SerialNumber
    AssetId      = $NewDevice.InventoryNumber
  }
  New-UMSDevice @NewDeviceParams
}

Please note, I also add the inventory number as Asset ID, so that in case the device is renamed back to default IGEL naming convention TC+UnitID (happens sometimes) you can still assign the devices according to the asset information.

If all goes well, I get an output like that:

...

Mac      : 00E0C52375EB
Message  : Device successfully inserted.
Name     : DEV-2843
ParentId : -1

Mac      : 00E0C52375EB
Message  : Device successfully inserted.
Id       : 1975
Name     : DEV-2824
ParentId : -1

Mac      : 00E0C52375EC
Message  : Device successfully inserted.
Id       : 1976
Name     : DEV-2844
ParentId : -1

...

New devices in the UMS:
New Devices

Below the complete script:

$PSDefaultParameterValues = @{
  '*-UMS*:Computername'          = 'igelrmserver'
  'New-UMSAPICookie:Credential' = (Get-Credential)
}
$PSDefaultParameterValues += @{
  '*-UMS*:WebSession' = New-UMSAPICookie
}

$Path = 'C:\Temp\'

$IGELImportFile = '{0}2260123456-000010.csv' -f $Path
$AssetExportFile = '{0}Assets.csv' -f $Path

$IGELImportColl = Import-Csv -Delimiter ';' -Path $IGELImportFile -Header '0', 'SerialNumber', 'MacAddress', '3', '4'
$AssetExportColl = Import-Csv -Delimiter ';' -Path $AssetExportFile

$DevicePrefix = 'DEV-'
$MajorVersion = 10

$FirmwareId = (((Get-UMSFirmware).where{ $_.Version.Major -eq $MajorVersion } |
      Sort-Object -Property Version -Descending)[0]).Id

$NewDeviceCollParams = @{
  Left              = $IGELImportColl
  LeftJoinProperty  = 'SerialNumber'
  LeftProperties    = 'SerialNumber', 'MacAddress'
  Right             = $AssetExportColl
  RightJoinProperty = 'SerialNumber'
  RightProperties   = 'InventoryNumber'
  Type              = 'AllInLeft'
}
$NewDeviceColl = Join-Object @NewDeviceCollParams

foreach ($NewDevice in $NewDeviceColl)
{
  $NewDeviceParams = @{
    Mac          = $NewDevice.MacAddress
    FirmwareId   = $FirmwareId
    Name         = '{0}{1}' -f $DevicePrefix, $NewDevice.InventoryNumber
    SerialNumber = $NewDevice.SerialNumber
    AssetId      = $NewDevice.InventoryNumber
  }
  New-UMSDevice @NewDeviceParams
}

Comments (2)

  1. Thanks for sharing this. I am going to see if I can incorporate the steps outlined, but to setup the names from a predefined list matching client to host name. One thing I was thinking was if this can be incorporated into an on demand service. For example onsite tech, setup’s new client, then send an email with MAC address and name desired, then script handles the naming of client in UMS and on client.

    • maybe i am getting it wrong, but when the onsite tech sets up a new client, he can set a name for the device in the process as well.

      In case you mean your onsite tech gets a bunch of devices and has a list (mac, name) for those devices, he could put this list in a fileshare. You could than automate a script (f.i. via jenkins) to read in the list, rename the clients and remove the list.

      please let me know if this was not what you were going for.

Comment here