<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									How To Manage and Audit vSphere Permissions with PowerCLI - VMware vSphere help				            </title>
            <link>https://www.virtualizationhowto.com/community/vmware-vsphere-help/how-to-manage-and-audit-vsphere-permissions-with-powercli/</link>
            <description>Virtualization Howto Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Sat, 06 Jun 2026 22:57:01 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>How To Manage and Audit vSphere Permissions with PowerCLI</title>
                        <link>https://www.virtualizationhowto.com/community/vmware-vsphere-help/how-to-manage-and-audit-vsphere-permissions-with-powercli/#post-1151</link>
                        <pubDate>Wed, 29 Jan 2025 13:50:56 +0000</pubDate>
                        <description><![CDATA[PowerCLI is a great way to automate processes and activities in vSphere. You can use PowerCLI for to manage and audit vSphere permissions, which is a great way to pull these using scripts, e...]]></description>
                        <content:encoded><![CDATA[<p>PowerCLI is a great way to automate processes and activities in vSphere. You can use PowerCLI for to manage and audit vSphere permissions, which is a great way to pull these using scripts, etc.</p>
<h2 id="what-are-vsphere-permissions" class="wp-block-heading">What are vSphere Permissions?</h2>
<p>What exactly are vSphere Permissions, and what do they allow you to do? They detail what a user can do in the vSphere environment. When you create permissions, these get assigned to roles. You can then assign these to users or groups.</p>
<h2 id="vmware-powercli-install" class="wp-block-heading">VMware PowerCLI install</h2>
<p>To work with permissions, roles, etc, you will need to install VMware.PowerCLI module. It is easy to install with the command:</p>
<pre class="wp-block-code" contenteditable="false"><code>Install-Module VMware.PowerCLI</code></pre>
<p>We will use this module and associated cmdlets in the rest of the walkthrough below.</p>
<h2 id="connect-to-vcenter-server" class="wp-block-heading">Connect to vCenter Server</h2>
<p>First let’s connect to vCenter Server.</p>
<pre class="wp-block-code" contenteditable="false"><code># Connect to vCenter Server
Connect-VIServer -Server vcenter-server-address -User username -Password password</code></pre>
<h2 id="list-roles-and-vsphere-permissions-powercli" class="wp-block-heading">List roles and vSphere permissions PowerCLI</h2>
<p>Let’s list the available roles in vSphere using the cmdlet:</p>
<pre class="wp-block-code" contenteditable="false"><code>Get-VIRole</code></pre>
<div class="wp-block-image">
<figure>
485
<br />
<figcaption class="wp-element-caption">get-virole</figcaption>
</figure>
</div>
<p>PowerCLI provides a command to list all available privileges in vCenter. This can be a helpful command for understanding privileges.</p>
<pre class="wp-block-code" contenteditable="false"><code># List all available privileges
Get-VIPrivilege</code></pre>
<div class="wp-block-image">
<figure>
486
<br />
<figcaption class="wp-element-caption">get-viprivilege</figcaption>
</figure>
</div>
<p><strong>Checking Specific User Permissions</strong></p>
<p>To check the permissions assigned to a specific user, use:</p>
<pre class="wp-block-code" contenteditable="false"><code># Check permissions for a specific user
Get-VIPermission -Principal "User1"</code></pre>
<h2 id="assigning-privileges-to-roles" class="wp-block-heading">Assigning Privileges to Roles</h2>
<p>Assigning privileges to roles is important. You can create a new role and assign specific privileges using PowerCLI. As always you don’t want to assign more privileges than needed. Below, we are assigning the permissions to power on VMs to a new role called “<strong>CustomRole</strong>“.</p>
<pre class="wp-block-code" contenteditable="false"><code># Create a new role with specific privileges 
New-VIRole -Name "CustomRole" -Privilege (Get-VIPrivilege -Id "VirtualMachine.Interact.PowerOn")</code></pre>
<div class="wp-block-image">
<figure>
487
<br />
<figcaption class="wp-element-caption">creating a new vi role using the new-virole cmdlet in powercli</figcaption>
</figure>
</div>
<h2 id="changing-existing-roles" class="wp-block-heading">Changing Existing Roles</h2>
<p>To modify an existing role, adding or removing privileges, use the commands that follow:</p>
<pre class="wp-block-code" contenteditable="false"><code># Add a privilege to an existing role
Set-VIRole -Role "CustomRole" -AddPrivilege (Get-VIPrivilege -Id "VirtualMachine.Interact.PowerOff")

# Remove a privilege from an existing role
Set-VIRole -Role "CustomRole" -RemovePrivilege (Get-VIPrivilege -Id "VirtualMachine.Interact.PowerOn")</code></pre>
<div class="wp-block-image">
<figure>
488
<br />
<figcaption class="wp-element-caption">setting the vi-role using PowerCLI</figcaption>
</figure>
</div>
<h2 id="assigning-and-propagating-permissions" class="wp-block-heading">Assigning and Propagating Permissions</h2>
<p>Permissions link roles with users or groups. To create a permission and assign it in your environment:</p>
<pre class="wp-block-code" contenteditable="false"><code># Assign a role to a user at a specific level
New-VIPermission -Entity (Get-VM -Name "VM1") -Principal "User1" -Role "CustomRole" -Propagate:$true</code></pre>
<div class="wp-block-image">
<figure>
489
<br />
<figcaption class="wp-element-caption">adding permissions using powercli new-vipermission cmdlet</figcaption>
</figure>
</div>
<p>When assigning permissions, you will likely want to propagate them to child objects in the environment. Here’s how you do that:</p>
<pre class="wp-block-code" contenteditable="false"><code># Assign and propagate permissions to child objects
New-VIPermission -Entity (Get-Cluster -Name "Cluster1") -Principal "User1" -Role "CustomRole" -Propagate:$true</code></pre>
<div class="wp-block-image">
<figure>
490
<br />
<figcaption class="wp-element-caption">propagating permissions using powercli</figcaption>
</figure>
</div>
<h2 id="managing-user-and-group-permissions" class="wp-block-heading">Managing User and Group Permissions</h2>
<p>To manage local users, groups, and policies in vSphere using PowerCLI, you need to leverage an open-source module called<span> </span><strong>VMware.vSphere.SsoAdmin</strong>. Check out the official VMware blog here:<span> </span><a href="https://blogs.vmware.com/PowerCLI/2020/10/new-open-source-powercli-module-for-managing-vcenter-single-sign-on-sso.html">New Open Source PowerCLI Module for managing vCenter Single Sign-On (SSO) – VMware PowerCLI Blog</a>.</p>
<p>By default, if you just install the<span> </span><strong>VMware.PowerCLI</strong><span> </span>module, you can’t manage local SSO users and groups and policies. This SSOAdmin module includes cmdlets to manage Single Sign-On (SSO) users and groups within the vSphere environment.</p>
<p>To install the module, you can use the cmdlet:</p>
<pre class="wp-block-code" contenteditable="false"><code>Install-Module VMware.vSphere.SsoAdmin</code></pre>
<div class="wp-block-image">
<figure>
491
<br />
<figcaption class="wp-element-caption">installing the module needing to work with the vi sso domain</figcaption>
</figure>
</div>
<p><strong>Connecting to the SSOAdmin Server</strong></p>
<p>This module has its own connect command that needs to be used in the form of:</p>
<pre class="wp-block-code" contenteditable="false"><code>connect-ssoadminserver -server vcsa.cloud.local -user administrator@vsphere.local -skipcertificatecheck</code></pre>
<div class="wp-block-image">
<figure>
492
<br />
<figcaption class="wp-element-caption">connecting to the ssoadminserver using the new powercli module</figcaption>
</figure>
</div>
<p><strong>Creating a new SSO user</strong></p>
<p>With the new module installed, we can create a new user in the SSO domain, using the cmdlet<span> </span><strong>New-SsoPersonUser</strong>:</p>
<pre class="wp-block-code" contenteditable="false"><code>New-SsoPersonUser -User mytestadmin -Password 'MyStrongPa$$w0rd' -EmailAddress 'mytestadmin@vsphere.local' -FirstName 'My' -LastName 'Admin'</code></pre>
<div class="wp-block-image">
<figure>
493
<br />
<figcaption class="wp-element-caption">creating a new sso user</figcaption>
</figure>
</div>
<div class="wp-block-image">
<figure>
494
<br />
<figcaption class="wp-element-caption">viewing the new user in the vsphere client</figcaption>
</figure>
</div>
<p><strong>Creating a New Group</strong></p>
<p>Also, you can create a new group using the<span> </span><strong>New-SsoGroup</strong><span> </span>cmdlet:</p>
<pre class="wp-block-code" contenteditable="false"><code># Create a new group in the local SSO domain 
New-SsoGroup -Name 'myGroup' -Description 'My Group Description'</code></pre>
<div class="wp-block-image">
<figure>
495
<br />
<figcaption class="wp-element-caption">creating a new sso group using powercli</figcaption>
</figure>
</div>
<p><strong>Assigning Users to Groups</strong></p>
<p>Once you have created users and groups, you can assign users to groups using the<span> </span><strong>Add-SsoGroupMember</strong><span> </span>cmdlet:</p>
<pre class="wp-block-code" contenteditable="false"><code>#Get the group details
$administratorsGroup = Get-SsoGroup -Name 'Administrators' -Domain 'vsphere.local'

#Add the user to the group
Get-SsoPersonUser -Name 'TestUser' -Domain 'MyDomain' | Add-UserToSsoGroup -TargetGroup $administratorsGroup</code></pre>
<h4 id="assigning-roles-to-users-and-groups" class="wp-block-heading">Assigning Roles to Users and Groups</h4>
<pre class="wp-block-code" contenteditable="false"><code># Assign a role to a user 
Set-VIPermission -Entity (Get-Datacenter -Name "Datacenter1") -Principal "vsphere.local\newuser" -Role "CustomRole" 

# Assign a role to a group 
Set-VIPermission -Entity (Get-Datacenter -Name "Datacenter1") -Principal "vsphere.local\newgroup" -Role "CustomRole"</code></pre>
<h2 id="roles-with-powercli" class="wp-block-heading">Roles with PowerCLI</h2>
<p>Creating custom roles for your permissions needs:</p>
<pre class="wp-block-code" contenteditable="false"><code># Create a new role with specific privileges
New-VIRole -Name "BackupAdmin" -Privilege (Get-VIPrivilege -Id "Datastore.AllocateSpace", "Datastore.Browse")</code></pre>
<h3 id="deleting-roles" class="wp-block-heading">Deleting Roles</h3>
<p>You can also delete roles this way:</p>
<pre class="wp-block-code" contenteditable="false"><code># Delete an existing role
Remove-VIRole -Role "BackupAdmin"</code></pre>
<h2 id="importing-and-exporting-permissions" class="wp-block-heading">Importing and Exporting Permissions</h2>
<p>You can export permissions as well for backup, as an example:</p>
<pre class="wp-block-code" contenteditable="false"><code># Export permissions to a file
Get-VIPermission | Export-Csv -Path "permissions.csv"</code></pre>
<h3 id="importing-permissions" class="wp-block-heading">Importing Permissions</h3>
<p>To import permissions from a file:</p>
<pre class="wp-block-code" contenteditable="false"><code># Import permissions from a file
Import-Csv -Path "permissions.csv" | ForEach-Object {
    New-VIPermission -Entity (Get-View -Id $_.Entity) -Principal $_.Principal -Role $_.Role -Propagate:$_.Propagate
}</code></pre>]]></content:encoded>
						                            <category domain="https://www.virtualizationhowto.com/community/vmware-vsphere-help/">VMware vSphere help</category>                        <dc:creator>Brandon Lee</dc:creator>
                        <guid isPermaLink="true">https://www.virtualizationhowto.com/community/vmware-vsphere-help/how-to-manage-and-audit-vsphere-permissions-with-powercli/#post-1151</guid>
                    </item>
							        </channel>
        </rss>
		