Solved

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

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…

747 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

11 Experts available now in Live!

Get 1:1 Help Now