Basically, I want to know how to set the scope for a hyper-v vm in Server 2012 R2 so users see only the specific vm's assigned to them. I work at an academic institution, we intend to upgrade our 2008 R2 servers to 2012 R2 but before we can do that we
need our vm creation script to work properly. In older editions that have the WMI v1 namespace it used to be to set the scope for a vm you did so by modifying Msvm_VirtualSystemGlobalSettingData.ScopeOfResidence. In the WMI v2 namespace Msvm_VirtualSystemGlobalSettingData
has been removed and most of its features have been placed in Msvm_VirtualSystemSettingData. ScopeOfResidence however is not in there and I can't find it or anything that sounds the same in any of the virtual system classes. Below is the unedited portion of
the old script I am having trouble converting to the v2 namespace. Someone please help, I need this working by the end of the month or I am going to have to abandon the server upgrade entirely.
# Set Scope!
$VM_Service = get-wmiobject -namespace root\virtualization Msvm_VirtualSystemManagementService
$ListofVMs = get-wmiobject -namespace root\virtualization Msvm_ComputerSystem -filter "ElementName <> Name " | `
where { $_.ElementName -like $vmName }
foreach ($VirtualMachine in $ListofVMs) {
if ($VirtualMachine -ne $Null)
{
$VMGlobalSetting = get-wmiobject -namespace root\virtualization Msvm_VirtualSystemGlobalSettingData | where `
{ $_.ElementName -like "*$($VirtualMachine.ElementName)*" }
$VMGlobalSetting.ScopeOfResidence = $scope
$VM_Service.ModifyVirtualSystem($VirtualMachine.__PATH, $VMGlobalSetting.psbase.Gettext(1))
}
Write-Host "Virtual Machine" $vmName "Added to Scope" $scope
}
# End of Set Scope