Skip to content

New command: m365 viva engage role list. Closes #6796 #6798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions docs/docs/cmd/viva/engage/engage-role-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import Global from '/docs/cmd/_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# viva engage role list

Retrieves the roles that can be assigned in Viva Engage

## Usage

```sh
m365 viva engage role list [options]
```

## Options

<Global />

## Remarks

:::warning

This command is based on an API that is currently in preview and is subject to change once the API reaches general availability.

:::

## Examples

List all Viva Engage roles

```sh
m365 viva engage role list
```

## Response

<Tabs>
<TabItem value="JSON">

```json
[
{
"id": "ec759127-089f-4f91-8dfc-03a30b51cb38",
"displayName": "Network Admin"
},
{
"id": "966b8ec4-6457-4f22-bd3c-5a2520e98f4a",
"displayName": "Verified Admin"
},
{
"id": "77aa47ad-96fe-4ecc-8024-fd1ac5e28f17",
"displayName": "Corporate Communicator"
}
]
```

</TabItem>
<TabItem value="Text">

```text
id displayName
------------------------------------ ----------------------
ec759127-089f-4f91-8dfc-03a30b51cb38 Network Admin
966b8ec4-6457-4f22-bd3c-5a2520e98f4a Verified Admin
77aa47ad-96fe-4ecc-8024-fd1ac5e28f17 Corporate Communicator
```

</TabItem>
<TabItem value="CSV">

```csv
id,displayName
ec759127-089f-4f91-8dfc-03a30b51cb38,Network Admin
966b8ec4-6457-4f22-bd3c-5a2520e98f4a,Verified Admin
77aa47ad-96fe-4ecc-8024-fd1ac5e28f17,Corporate Communicator
```

</TabItem>
<TabItem value="Markdown">

```md
# viva engage role list

Date: 7/11/2025

## Network Admin (ec759127-089f-4f91-8dfc-03a30b51cb38)

Property | Value
---------|-------
id | ec759127-089f-4f91-8dfc-03a30b51cb38
displayName | Network Admin

## Verified Admin (966b8ec4-6457-4f22-bd3c-5a2520e98f4a)

Property | Value
---------|-------
id | 966b8ec4-6457-4f22-bd3c-5a2520e98f4a
displayName | Verified Admin

## Corporate Communicator (77aa47ad-96fe-4ecc-8024-fd1ac5e28f17)

Property | Value
---------|-------
id | 77aa47ad-96fe-4ecc-8024-fd1ac5e28f17
displayName | Corporate Communicator
```

</TabItem>
</Tabs>
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4907,6 +4907,11 @@ const sidebars: SidebarsConfig = {
label: 'engage report groupsactivitygroupcounts',
id: 'cmd/viva/engage/engage-report-groupsactivitygroupcounts'
},
{
type: 'doc',
label: 'engage role list',
id: 'cmd/viva/engage/engage-role-list'
},
{
type: 'doc',
label: 'engage user get',
Expand Down
1 change: 1 addition & 0 deletions src/m365/viva/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
ENGAGE_REPORT_GROUPSACTIVITYCOUNTS: `${prefix} engage report groupsactivitycounts`,
ENGAGE_REPORT_GROUPSACTIVITYDETAIL: `${prefix} engage report groupsactivitydetail`,
ENGAGE_REPORT_GROUPSACTIVITYGROUPCOUNTS: `${prefix} engage report groupsactivitygroupcounts`,
ENGAGE_ROLE_LIST: `${prefix} engage role list`,
ENGAGE_SEARCH: `${prefix} engage search`,
ENGAGE_USER_GET: `${prefix} engage user get`,
ENGAGE_USER_LIST: `${prefix} engage user list`
Expand Down
4 changes: 4 additions & 0 deletions src/m365/viva/commands/engage/EngageRole.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface EngageRole {
id?: string;
displayName?: string;
}
35 changes: 35 additions & 0 deletions src/m365/viva/commands/engage/engage-role-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Logger } from '../../../../cli/Logger.js';
import { odata } from '../../../../utils/odata.js';
import GraphCommand from '../../../base/GraphCommand.js';
import commands from '../../commands.js';
import { EngageRole } from './EngageRole.js';

class VivaEngageRoleListCommand extends GraphCommand {
public get name(): string {
return commands.ENGAGE_ROLE_LIST;
}

public get description(): string {
return 'Lists all Viva Engage roles';
}

public defaultProperties(): string[] | undefined {
return ['id', 'displayName'];
}

public async commandAction(logger: Logger): Promise<void> {
if (this.verbose) {
await logger.logToStderr('Getting all Viva Engage roles...');
}

try {
const results = await odata.getAllItems<EngageRole>(`${this.resource}/beta/employeeExperience/roles`);
await logger.log(results);
}
catch (err: any) {
this.handleRejectedODataJsonPromise(err);
}
}
}

export default new VivaEngageRoleListCommand();