Solved

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

Posted on 2016-11-14
2
74 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …

734 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