# CMS_GetLinkedPackages

> The function returns which packages is linked to the current Unit.

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

:::note[Important]
Available from Version 6.7.108
:::

### Description

The function returns which packages is linked to the current Unit

### Syntax

**VBScript**

```vb
CMS_GetLinkedPackages() As Boolean
```

**PowerShell**

```powershell
[CiUnitPackage[]]CMS_GetLinkedPackages
```

### Return value

**VBScript**

Result will be stored in gaValue

**PowerShell**

The function will return an array of the type CiUnitPackage:

```powershell
class CiUnitPackage {
  [int]$Jobid
  [int]$Type
  [string]$Name
  [string]$Version
  [string]$Status
  [DateTime]$Lastrundate
  [DateTime]$Laststatuschange
}
```

### Example

**VBScript**

```vb
If bStatus Then bStatus = CMS_GetLinkedPackages()      
For index = LBound(gaValue) to UBound(gaValue)   
  xStatus = Job_WriteLog("Custom", "Index #" & index & ": '" & cStr(gaValue(index)) & "'", bStatus, True)   
Next
```

**PowerShell**

```powershell
CMS_GetLinkedPackages | ForEach-Object {
  $cs.Job_WriteLog("Jobid: ", $_.Jobid)
  $cs.Job_WriteLog("Type: ", $_.Type)
  $cs.Job_WriteLog("Name: ", $_.Name)
  $cs.Job_WriteLog("Version: ", $_.Version)
  $cs.Job_WriteLog("Status: ", $_.Status)
  $cs.Job_WriteLog("Lastrundate: ", $_.Lastrundate)
  $cs.Job_WriteLog("Laststatuschange: ", $_.Laststatuschange)
  $cs.Job_WriteLog("------","------")
} 

# Expected output:
2026-05-28 13:01:05 - Install: Jobid:  3282
2026-05-28 13:01:05 - Install: Type:  1
2026-05-28 13:01:05 - Install: Name:  .NET 8 Desktop Runtime 8.0.24
2026-05-28 13:01:05 - Install: Version:  v2.0
2026-05-28 13:01:05 - Install: Status:  Installed
2026-05-28 13:01:05 - Install: Lastrundate:  05/28/2026 10:31:12
2026-05-28 13:01:05 - Install: Laststatuschange:  05/28/2026 10:31:14
2026-05-28 13:01:05 - Install: ------ ------
2026-05-28 13:01:05 - Install: Jobid:  2246
2026-05-28 13:01:05 - Install: Type:  1
2026-05-28 13:01:05 - Install: Name:  Baretail
2026-05-28 13:01:05 - Install: Version:  v2025.11
2026-05-28 13:01:05 - Install: Status:  Installing
2026-05-28 13:01:05 - Install: Lastrundate:  11/14/2025 13:20:25
2026-05-28 13:01:05 - Install: Laststatuschange:  11/14/2025 13:20:18
```

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

### Related functions

[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/)
