Adding roles with privileges from powercli


This will be very quick and short one 😉
We can easily create a role within our VC using the new-virole cmdlet. Since it accepts the privilege IDs as an array we can first fill up our array with privileges and then give it to new-virole.
In order to see from which we can run get-viprivilege to get all of them first. If you already know which one to include :

$privs_for_role=@(
'System.Anonymous',
'System.View',
'System.Read')
New-VIRole -Name custom_role1 -Privilege (Get-VIPrivilege -id $privs_for_role)

the -Privilege accepts only privileges, so we first need to get them using get-viprivilege and giving id name so we will receive privilege object.

Advertisements

3 thoughts on “Adding roles with privileges from powercli

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s