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

Badges
MCSE
Community

Cozumpark Bilisim Portali
Changing UserRole of some Virtual Machines on SCVMM 2012 SP1
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | No Comment | 2,443 views | 26/07/2013 12:06

You can change UserRoles of virtual machines on SCVMM 2012 SP1 with following command:

1
2
3
4
5
6
$VMs = Get-VM | Where Name -like "*CALL*" | Where UserRole -eq $Null
foreach ($VM in $VMs)
{
	$UserRole = Get-SCUserRole "MyUserRole"
	$VM | Set-VM -Owner "DOMAIN\Owner" -UserRole $UserRole
}

That will only change “null” user roles. If you want to change existing user roles:

1
2
3
4
5
6
$VMs = Get-VM | Where Name -like "*CALL*" | Where UserRole -like "OldUserRole"
foreach ($VM in $VMs)
{
	$UserRole = Get-SCUserRole "NewUserRole"
	$VM | Set-VM -Owner "DOMAIN\Owner" -UserRole $UserRole
}

It will only looks for VMs like “CALL”. You can leave it blank for all virtual machines.



Leave a Reply