Solved

Adding full "Virtual machine" privilege to a role over PowerCLI

Posted on 2016-11-14
2
45 Views
Last Modified: 2016-12-07
I've set up some very simple scripts to set up some roles on hosts and add permissions to those roles. I've been able to get other privileges in there ("resource","datastore",etc), but for some reason I can't add the "Virtual machine" permission or group. If I run get-viprivilege -name "virtual machine" it gives me the result of Virtual machine meaning it's there, right? I've even tried using the get-viprivilege results as my target and no luck. Is there some other name I need to provide for it to know I'm looking for everything under the Virtual machine category?

$hosts=(get-vmhost|select Name)
$hosts|%{set-virole -server $_.Name -role <ROLENAME> -addprivilege "Virtual machine","resource","Datastore","vApp","Performance"}
0
Comment
Question by:Dustin Wade
2 Comments
 
LVL 12

Accepted Solution

by:
Dustin Saunders earned 500 total points
ID: 41886940
There's a problem with setting Virtual Machine that way because it's nested under another layer of options.  You need to get all those options first, then set them.

$p = Get-VIPrivilege | ?{$_.ParentGroupID -like "VirtualMachine*"}
Set-VIRole "rolename" -AddPrivilege $p

Open in new window


This would apply all the resulting Virtual Machine privileges.
*note the edit, forgot a part of the code.
0
 

Assisted Solution

by:Dustin Wade
Dustin Wade earned 0 total points
ID: 41887013
Ok, awesome. I was able to modify this into what I was using so now I have the following which will find this permission and add it to all of our esxi hosts:


$hosts=(get-vmhost|select Name)
$hosts|%{
$priv = Get-VIPrivilege -server $_.Name| ? {$_.ParentGroupID -like "VirtualMachine*"}
set-virole -server $_.Name -role <ROLE> -addprivilege $priv
}

Thanks, Bahman
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When converting a physical machine to a virtual machine using VMware vCenter Converter Standalone or vCenter Converter Enterprise, if an adapter type is not selected during the initial customization the resulting virtual machine may contain an IDE d…
A brief introduction to what I consider to be the best editor for PowerShell.
Teach the user how to install vSphere Update Manager  Console to Windows system:  Install vSphere Update Manager: Configure vSphere Update Manager plug-in in vSphere Client: Verify vSphere Update Manager settings in vSphere Client:
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now