# CMS_AddHardwareInventory

> Adds a HardwareInventory row to the database that is persistent, meaning that the data will not be flushed out the next time that the HardwareInventory package is run.

Source: https://docs.capaone.com/capainstaller/vb-scripting-library/cms-functions/cms-addhardwareinventory/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Adds a HardwareInventory row to the database that is persistent, meaning that the data will not be flushed out the next time that the HardwareInventory package is run.

:::note[Important]
### Please note

Please note, that this is an expensive call, seen from the Frontend/database perspective. Calling this function repeatedly from a package could result in overall slower performance. This function should be used with care.
:::

### Syntax

**VBScript**

```vb
CMS_AddHardwareInventory(category, entry, value, valuetype)
```

**PowerShell**

```powershell
[bool] CMS_AddHardwareInventory -category <string> -entry <string> -value <string> -valuetype <string>
```

### Parameters

#### category (String)

Category name

#### entry (String)

variable name

#### value (string)

value (string)

If you are inserting a Time (valuetype: "T") it must be set in epoch-time, meaning seconds since January 1. 1970. The scripting library has a function called GetEpochTime, which will convert a date to seconds since 1-1-1970.

If you want to use 'now' as the value, you can either insert;

- an empty string ("")
- or the value ("0")

#### valuetype (string)

The type of the value

Valid valuetypes are;

- "S" for string
- "I" for integer
- "T" for time

### Return value

**VBScript**

Boolean, TRUE if function completed successfully.

**PowerShell**

Boolean, TRUE if function completed successfully.

### Example

**VBScript**

```vb
If bStatus Then bStatus = CMS_AddHardwareInventory("BIOS Information", "Socket type", "Mill-A" "S")
If bStatus Then bStatus = CMS_AddHardwareInventory("CPU", "Fan speed", "1360" "I")
If bStatus Then bStatus = CMS_AddHardwareInventory("Sound Adapter", "SoundBlaster compatiple", "True" "S")
```

**PowerShell**

```powershell
CMS_AddHardwareInventory 'BIOS Information' 'Socket type' 'Mill-A' 'S'

CMS_AddHardwareInventory -category 'CPU -entry 'Fan speed' -value '1360' -valuetype 'I'

if (CMS_AddHardwareInventory 'Sound Adapter' 'SoundBlaster compatiple' 'True' 'S') {
  $cs.Job_WriteLog("Added", "Added SoundBlaster adapter to Hardware inventory")
}
```

[Scripting Guidelines](/capainstaller/vb-scripting-library/scripting-guidelines/)

### Related functions

[CMS_RemoveHardwareInventory](/capainstaller/vb-scripting-library/cms-functions/cms-removehardwareinventory/) [Constants](/capainstaller/vb-scripting-library/addendum/constants/) [Package Property](/capainstaller/vb-scripting-library/addendum/package-property/) [Variables](/capainstaller/vb-scripting-library/addendum/variables/) [Business Unit support](/capainstaller/vb-scripting-library/addendum/business-unit-support/)
