Solved

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

Posted on 2016-11-14
2
52 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
Teach the user how to install ESXi 5.5 and configure the management network System Requirements: ESXi Installation:  Management Network Configuration: Management Network Testing:
Teach the user how to rename, unmount, delete and upgrade VMFS datastores. Open vSphere Web Client: Rename VMFS and NFS datastores: Upgrade VMFS-3 volume to VMFS-5: Unmount VMFS datastore: Delete a VMFS datastore:

776 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