# CMS_GetGroupMembership

> The function returns which groups the current Unit is a member of.

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

### Description

The function returns which groups the current Unit is a member of

For Business Unit support click [Business Unit support](/capainstaller/vb-scripting-library/addendum/business-unit-support/)

### Syntax

**VBScript**

```vb
CMS_GetGroupMembership() As Boolean
```

**PowerShell**

```powershell
[CiGroup[]]CMS_GetGroupMembership
```

### Return value

**VBScript**

Result will be stored in gaValue

**PowerShell**

The function will return an array of the type CiGroup:

```powershell
class CiGroup {
  [string]$Unittype
  [int]$Id
  [string]$Name
  [string]$Description
  [string]$Type
  [string]$Typedisplayname
  [string]$Icon
  [int]$Cmpid
  [string]$Scheduleid
  [bool]$Groupdeleted
  [string]$Businessunitid
  [int]$Linkedprofilecount
  [int]$Linkedapplicationcount
  [int]$Linkedpackagecount
  [int]$Linkedunitcount
  [int]$Folderid
  [string]$Guid
  [string]$Objecttype
  [int]$Parentid
  [int]$Packagetype
  [int]$Reinstallid
  [string]$Mode
  [DateTime]$Lastexecuted
  [int]$Pointid
  [int]$Osimageid
  [int]$Diskconfigid
  [int]$Installtypeid
  [int]$Osserverid
  [bool]$Clearallpackages
  [bool]$Clearallpackagesandgroups
  [object]$Customfield1
  [object]$Customfield2
}
```

### Example

**VBScript**

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

**PowerShell**

```powershell
CMS_GetGroupMembership | ForEach-Object {
  $cs.Job_WriteLog("Group Name: ", $_.Name)
  $cs.Job_WriteLog("Description: ", $_.Description)
  $cs.Job_WriteLog("Type: ", $_.Type)
  $cs.Job_WriteLog("TypeDisplayName: ", $_.Typedisplayname)
  $cs.Job_WriteLog("Id: ", $_.Id)
  $cs.Job_WriteLog("Guid: ", $_.Guid)
  $cs.Job_WriteLog("CmpID: ", $_.Cmpid)
  $cs.Job_WriteLog("------","------")
} 
  
# Expected output:
2023-11-19 20:38:25 - Group Name:  calendar1
2023-11-19 20:38:25 - Description:  First Calendar
2023-11-19 20:38:25 - Type:  1
2023-11-19 20:38:25 - TypeDisplayName:  Calendar
2023-11-19 20:38:25 - Id:  5027
2023-11-19 20:38:25 - Guid:  20e9a444-62c1-464e-bf6f-5994fd47f37a
2023-11-19 20:38:25 - CmpID:  1
2023-11-19 20:38:25 - ------ ------
2023-11-19 20:38:25 - Group Name:  Static One
2023-11-19 20:38:25 - Description:  First Static test group
2023-11-19 20:38:25 - Type:  7
2023-11-19 20:38:25 - TypeDisplayName:  Static
2023-11-19 20:38:25 - Id:  5025
2023-11-19 20:38:25 - Guid:  6b11640d-8303-4b92-8090-e646d025f9cf
2023-11-19 20:38:25 - CmpID:  1
2023-11-19 20:38:25 - ------ ------
  
```

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