Custom vCenter roles and permissions with PowerCLI for Australian admins
Managing who can do what inside vCenter Server is one of those tasks that often gets pushed to the bottom of the to-do list until an auditor arrives. Australian organisations working under the Essential Eight maturity model, financial firms aligning with APRA CPS 234, and government departments in places like Canberra and Brisbane all need granular access control that maps neatly onto their internal change-management processes. PowerCLI makes this work reproducible, scriptable, and easy to audit across multiple vCenters.
The shift from clicking through the role administration screen to scripting every adjustment pays off quickly. Once a few PowerCLI functions are in place, building a new environment for a client in Melbourne, standing up a test bed in Perth, or replicating access for a new ESXi host becomes a matter of running a handful of cmdlets rather than chasing screenshots.
Why custom roles beat default permissions
Out of the box, vCenter offers roles such as Read-Only, Administrator, and a handful of power-user variants. These rarely align with the principle of least privilege that most Australian security frameworks demand. A storage admin in Sydney probably should not be able to power off VMs, and a DBA responsible for SQL Server workloads does not require the ability to reconfigure distributed switches. Custom roles close that gap by exposing only the privileges each team genuinely needs.
When you map out access in a planning worksheet before roles creep into production, you can trace every change back to a documented business need. This matters when the Australian Cyber Security Centre asks for evidence of segregation of duties, or when an internal review flags a developer holding temporary elevated credentials longer than expected. Custom roles, applied through PowerCLI, produce a paper trail that survives both regulatory scrutiny and staff turnover.
Preparing your PowerCLI environment
Before writing any role logic, you need a clean working connection. Install the VMware PowerCLI module from the PowerShell Gallery, then authenticate using either a local account or, preferably, a federated identity through your organisation's single sign-on. Many Australian enterprises integrate vCenter with Microsoft Entra ID or Okta, which lets scripts run unattended using service principals rather than shared passwords.
Keep certificate warning suppression limited to trusted lab environments, and always store credentials using the Windows credential manager or a secrets management solution such as HashiCorp Vault. A typical session starts with Connect-VIServer -Server vc01.melbourne.corp.local and ends with Disconnect-VIServer -Server * -Confirm:$false. Keeping connection discipline consistent in a standard pattern reduces the risk of leaving an authenticated session open on a jump host.
Building the custom role with New-VIRole
The New-VIRole cmdlet is the workhorse for creating bespoke permission bundles. The key decision is what privileges to include, and that is where a small lookup table pays off. Many admins maintain a CSV listing friendly role names alongside the privilege strings they need, which makes the script readable and reviewable.
A simple approach is to define a hashtable of role definitions in the script, then iterate through it with foreach. For example, you might build a Storage-Admin-MEL role that includes datastore and storage policy privileges but excludes VM power operations. If you are extending the lab from a low-power home lab guide, the same role-building pattern applies to a single-host setup just as easily as to a stretched cluster across two data centres.
Once the role exists, validation matters more than creation. Use Get-VIPrivilege -Role to list exactly what has been granted, and compare that to the planning document. This step catches typos in privilege IDs, which are a common source of mysterious access failures during user acceptance testing.
Assigning permissions to users and groups
Roles are inert until they are linked to an entity and a principal. The New-VIPermission cmdlet wires the role to either an inventory object, such as a datacenter, cluster, resource pool, or VM folder, and a user or group. In Australian enterprises, assigning at the group level is almost always preferable because it survives HR changes without touching vCenter.
Aim to assign at the highest object that still keeps least privilege intact. A marketing team in Brisbane does not need cluster-wide access if their workloads live in a single resource pool. Assigning too high a level is one of the most common reasons a custom role review uncovers excessive access months later. If you are also working through vSphere Storage DRS tuning, the same scoped-assignment principle applies to storage-only teams.
Auditing and maintaining permissions
Permissions drift. People move teams, projects wrap, and short-term elevations get forgotten. A quarterly PowerCLI audit that exports every Get-VIPermission result to CSV gives you a snapshot you can diff against the previous run. Storing those CSVs in version control, alongside the role-defining scripts, creates an evidence pack that satisfies both internal audit and external regulators.
The same disciplined loop-and-validate pattern shows up in unexpected places on the blog, including an exploration of Pai Gow poker play logic that maps cleanly onto branching role checks. Schedule the audit, run it, and store the output where it cannot be quietly edited later.
Core cmdlets for role management
New-VIRoleandSet-VIRoleto define and adjust custom privilege bundlesGet-VIRoleandGet-VIPrivilegeto inspect what currently existsNew-VIPermission,Set-VIPermission, andRemove-VIPermissionto wire roles to principals and objectsGet-VIPermissionfor periodic exports used in compliance reporting
Best practices for permission hygiene
- Assign permissions to Active Directory groups rather than individual user accounts
- Build a naming convention that encodes the team, environment, and scope of each role
- Version-control every role script and store exported permission snapshots alongside the code
- Review temporary elevations monthly and remove anything that has outlived its purpose
If you want a head start, browse the free PowerCLI tools and icon packs available on Virtxpert, then adapt the role templates to match the privilege catalogue already approved in your change advisory board. Sign up for the newsletter to get notified when new scripts, including a vCenter permissions auditor, land in the resources section.