Posted
by
Bink on
on August 9 2008, 10:27 AM
with no comments
In previous posts, I have shown how to create Azman scopes and roles to delegate administration of Hyper-V virtual machines to domain users. Now that we have an AzMan scope, let’s see how you can apply it to a virtual machine or set of virtual machines.
Note: In Hyper-V, there is no GUI interface to assign a scope to a VM, you need to use the Hyper-V WMI API
In my example scenario, I have a set of VMs prefixed with “01_”and I want to delegate administration of those VMs to Student01 and only this account can view those VMs in Hyper-V mmc console. In Prt 4 and Part 5, I already created a scope called 01_Scope and some role definitions. Let’s apply this cope to 01_ VMs.
Script
$VM_Service = get-wmiobject -namespace root\virtualization Msvm_VirtualSystemManagementService
$ListofVMs =get-wmiobject -namespace root\virtualization Msvm_ComputerSystem -filter "ElementName <> Name " | `
where { $_.ElementName -like "01_*"}
foreach ($VM in $ListofVMs) {
if ( $VM -ne $Null)
{
$VMGlobalSetting = get-wmiobject -namespace root\virtualization Msvm_VirtualSystemGlobalSettingData | where `
{ $_.ElementName -like "*$($VM.ElementName)*" }
$VMGlobalSetting.ScopeOfResidence = “01_Scope”
$VM_Service.ModifyVirtualSystem($VM.__PATH, $VMGlobalSetting.psbase.Gettext(1))
}
}
Full Story At Source
21393 Views