# CMS_GetAdvertisedPackages

> Returns all packages advertised to the unit.

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

### Description

Returns all packages advertised to the unit

### Syntax

**VBScript**

```vb
CMS_GetAdvertisedPackages() As Boolean
```

**PowerShell**

```powershell
[CiAdvertisedPackage[]]CMS_GetAdvertisedPackages
```

### Return value

**VBScript**

Result will be stored in gaValue

**PowerShell**

The function will return an array of the type CiAdvertisedPackage;

```powershell
class CiAdvertisedPackage {
  [int]$Jobid
  [int]$Type
  [string]$Name
  [string]$Version
  [bool]$Uninstallscript
  [string]$Catalogname
  [string]$Description
  [int]$Advertiseddate
  [string]$Groupname
  [bool]$Autoexpand
}
```

### Example

**VBScript**

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

```

**PowerShell**

```powershell
foreach ($advpck in CMS_GetAdvertisedPackages) {
    $cs.Job_WriteLog("Package Name:", $advpck.Name)
    $cs.Job_WriteLog("Package Version:", $advpck.Version)
    $cs.Job_WriteLog("Catalog name:", $advpck.Catalogname)
    $cs.Job_WriteLog("JobId:", $advpck.Jobid)
    $cs.Job_WriteLog("----", "----")
}

# Expected output:
2023-11-19 20:14:04 - Package Name: The Brand New PowerPack 4.5 de
2023-11-19 20:14:04 - Package Version: v1.0
2023-11-19 20:14:04 - Catalog name: The Brand New PowerPack 4.5 de v1.0
2023-11-19 20:14:04 - JobId: 130
2023-11-19 20:14:04 - ---- ----
2023-11-19 20:14:04 - Package Name: The Pack Mule 3.0 eng
2023-11-19 20:14:04 - Package Version: v1.0
2023-11-19 20:14:04 - Catalog name: The Pack Mule 3.0 eng v1.0
2023-11-19 20:14:04 - JobId: 125
2023-11-19 20:14:04 - ---- ----
2023-11-19 20:14:04 - Package Name: The Six Pack 2.0
2023-11-19 20:14:04 - Package Version: v1.0
2023-11-19 20:14:04 - Catalog name: The Six Pack 2.0 v1.0
2023-11-19 20:14:04 - JobId: 127
2023-11-19 20:14:04 - ---- ----
2023-11-19 20:14:04 - Package Name: Welcome to the Packateria 3.33 it
2023-11-19 20:14:04 - Package Version: v1.0
2023-11-19 20:14:04 - Catalog name: Welcome to the Packateria 3.33 it v1.0
2023-11-19 20:14:04 - JobId: 161
2023-11-19 20:14:04 - ---- ----

```

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