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.