Files
PSProxmoxVE/src/PSProxmoxVE/Cmdlets/Users/GetPveGroupCmdlet.cs
T
Clint Branham 5c3dac9e27 refactor: seal all cmdlet classes, add missing OutputType and ConfirmImpact
Sealed 105 cmdlet classes that were not already sealed — cmdlets are leaf
classes and sealing enables compiler optimizations.

Added [OutputType(typeof(void))] to 53 cmdlets that were missing the
attribute. All 169 cmdlet files now declare OutputType.

Added ConfirmImpact.High to Suspend-PveVm and Restart-PveVm to match
the convention used by Stop-PveVm and Reset-PveVm.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 08:15:38 -05:00

43 lines
1.3 KiB
C#

using System.Linq;
using System.Management.Automation;
using PSProxmoxVE.Core.Models.Users;
using PSProxmoxVE.Core.Services;
namespace PSProxmoxVE.Cmdlets.Users
{
/// <summary>
/// <para type="synopsis">Lists Proxmox VE groups.</para>
/// <para type="description">
/// Returns all groups from the Proxmox VE access management system. Optionally
/// filter by a specific group ID.
/// </para>
/// </summary>
[Cmdlet(VerbsCommon.Get, "PveGroup")]
[OutputType(typeof(PveGroup))]
public sealed class GetPveGroupCmdlet : PveCmdletBase
{
/// <summary>Optional group ID to filter by.</summary>
[Parameter(Mandatory = false, Position = 0, ValueFromPipelineByPropertyName = true, HelpMessage = "Optional group ID to filter results.")]
public string? GroupId { get; set; }
protected override void ProcessRecord()
{
var session = GetSession();
var service = new UserService();
WriteVerbose("Getting groups...");
var groups = service.GetGroups(session);
if (!string.IsNullOrEmpty(GroupId))
{
groups = groups.Where(g => g.GroupId == GroupId).ToArray();
}
foreach (var group in groups)
{
WriteObject(group);
}
}
}
}