Website under construction



Download 13,37 Mb.
Pdf ko'rish
bet18/131
Sana27.03.2022
Hajmi13,37 Mb.
#512480
1   ...   14   15   16   17   18   19   20   21   ...   131
Bog'liq
9780735697744 Introducing Windows Server 2016 pdf

Creating VM collections 
The following new Windows PowerShell cmdlets have been introduced to facilitate scripting: 

New-VMGroup 

Get-VMGroup 

Remove-VMGroup 

Add-VMGroupMember 

Remove-VMGroupMember 

Rename-VMGroup 
As of this writing, VM group management tools are still being developed; however, they will be visible 
in Windows PowerShell, Hyper-V Manager, and the upcoming version of Microsoft System Center 
Virtual Machine Manager. 
To group together the three example VMs shown in Figure 2-2, you need to do the following: 
1.
Create a VM group. 
2.
Add the VMs to the group membership. 


14 
CHAPTER 2 | Software-defined datacenter 
Figure 2-2:
VM Groups 
The code that follows is a Windows PowerShell script that will accomplish our goals. Keep in mind that 
the VM group being created is a VM collection group. Only VM collection groups can have VMs 
directly placed within them. 
#Setup VM variables
$VM1 = Get-VM -Name VM1 
$VM2 = Get-VM -Name VM2 
$VM3 = Get-VM -Name VM3 
#Create new VM Group 
New-VMGroup -Name TestVMG1 -GroupType VMCollectionType 
#Setup VM Group variable 
$TestVMG1 = Get-VMGroup -Name TestVMG1 
#Add VMs to the group/collection 
Add-VMGroupMember -VMGroup $TestVMG1 -VM $VM1 
Add-VMGroupMember -VMGroup $TestVMG1 -VM $VM2 
Add-VMGroupMember -VMGroup $TestVMG1 -VM $VM3 
The result of these steps is a VM group that contains three VMs. 
You can verify this by using the management tools and querying either the VMs or the VM groups. 
The following example shows how to do this by utilizing the Get-VM and Get-VMGroup cmdlets, 
respectively: 
PS C:\> Get-VM | ft Name, state, groups - AutoSize 
Name State Groups 
---- ----- ------ 
VM1 Running {TestVMG1} 
VM2 Running {TestVMG1} 
VM3 Running {TestVMG1}
PS C:\> Get-VMGroup * | ft Name, vmmembers -AutoSize 
Name VMMembers 
---- --------- 
TestVMG1 {VM2, VM3, VM1} 
The updated Get-VM cmdlet lists what groups (if any) of which the VM is a member. A VM can be a 
member of multiple groups. If this is the case, the Get-VM cmdlet will return a list of multiple groups. 
The new Get-VMGroup lists any VMs that are members of a specified group, or, as in the preceding 
example, in which we use a wildcard, all existing groups. In the example, we query all groups because 
we know there is just one. However, we can add one of the VMs to the membership of second group. 
Here is a quick Windows PowerShell script that will do just that: 
#Create new VM Group 
New-VMGroup -Name TestVMG2 -GroupType VMCollectionType 
#Setup VM Group variable 
$TestVMG2 = Get-VMGroup -Name TestVMG2 
#Add VMs to the group 
Add-VMGroupMember -VMGroup $TestVMG2 -VM $VM1 


15 
CHAPTER 2 | Software-defined datacenter 
Using the Get-VM cmdlet, you can see that VM1 now belongs to both the TestVMG1 group and the 
new TestVMG2 group: 
PS C:\> Get-VM | ft Name, state, groups - AutoSize 
Name State Groups 
---- ----- ------ 
VM1 Running {TestVMG2, TestVMG1} 
VM2 Running {TestVMG1} 
VM3 Running {TestVMG1}
Using the Get-VMGroup cmdlet, you now see both groups and VM1 are members of both VM groups: 
PS C:\> Get-VMGroup * | ft Name, vmmembers -AutoSize 
Name VMMembers 
---- --------- 
TestVMG2 {VM1} 
TestVMG1 {VM2, VM3, VM1} 
There are now two VM groups: one comprising three VMs, and the other with a single VM, as shown 
in Figure 2-3. 

Download 13,37 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   ...   131




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish