search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
How to grant user role on VMs on SCVMM 2012 R2 via PowerShell
Posted in Virtual Machine Manager, Windows Powershell | No Comment | 1,811 views | 19/02/2014 17:05

You can grant user roles into Virtual Machines for AppController with following script:

1
2
3
4
5
6
7
8
9
$VMs = Get-VM
foreach ($VM in $VMs)
{
	$UserRole = $VM.UserRole.Name
	$UserRole = Get-SCUserRole -Name "$UserRole"
	$UserRoleID = $UserRole.ID.Guid
	$UserName = $VM.Owner
	Grant-SCResource -Resource $VM -UserName $UserName -UserRoleID @("$UserRoleID")
}

That will apply VM’s owner and UserRole as a granted user role.



Leave a Reply