[ Pobierz całość w formacie PDF ]
.ps1 performs the following tasks:1.Retrieves, from the Virtual Machine Manager database, all virtual machine host groups as an array and stores the host group objects in variable $VMHostGroups.2.Retrieves, from the Virtual Machine Manager database, all virtual machine objects as an array and stores the virtual machine objects in variable $VMs.3.For each host group, determines the following:ï‚· The number of hosts in the host group.ï‚· The number of virtual machines in the host group.ï‚· The number of running virtual machines on hosts in the host group.ï‚· The number of virtual machines that are allocated to self-service users in the host group.4.Displays the following information about each host group:ï‚· The name of the host group.ï‚· The number of hosts in the host group.ï‚· The number of virtual machines, running virtual machines, and self-service virtual machines in the host group.ï‚· The number of virtual machines on each host ($VMCount / $VMHostCount); the number of running virtual machines on each host ($RunningVMCount / $VMHostCount), and the number of self-service virtual machines on each host ($SelfServiceVMCount / $VMHostCount).##################################################################### Summary of Virtual Machine Host Groups####################################################################$VMHostGroups = @(Get-VMHostGroup)$VMs = @(Get-VM)Write-Host "`nVIRTUAL MACHINE HOST GROUPS" -ForegroundColor Yellowforeach ($VMHostGroup in $VMHostGroups){$VMHostCount = $VMHostGroup.Hosts.Count$VMCount = @($VMs | where {$VMHostGroup.Hosts -contains $_.VMHost}).Count$RunningVMCount = @($VMs | where {$VMHostGroup.Hosts -contains $_.VMHost} | where {$_.Status -eq "Running"}).Count$SelfServiceVMCount = @($VMs | where {$VMHostGroup.Hosts -contains $_.VMHost} | where {$_.SelfServicePolicy -ne $null}).CountWrite-Host "Host Group :", $VMHostGroup.NameWrite-Host "Number of Hosts :", $VMHostCountif ($VMHostCount -ne 0){Write-Host "Number of VMS :", $VMCountWrite-Host "Running VMs :", $RunningVMCountWrite-Host "Self-Service VMs :", $SelfServiceVMCountWrite-Host "VMs per Host :", ($VMCount / $VMHostCount)Write-Host "Running VMs per Host :", ($RunningVMCount / $VMHostCount)Write-Host "Self-Serice VMs per Host :", ($SelfServiceVMCount / $VMHostCount)}Write-Host}SummarizeVMMInformation.ps1 - Complete ScriptCopy the following complete version of SummarizeVMMInformation.ps1 into a Notepad file, and save it as SummarizeVMMInformation.# Filename: SummarizeVMMInformation.ps1# Description: Display information about Virtual Machine Manager# servers (including hosts and library servers),# host groups, virtual machines, and self-service# policies.# DISCLAIMER:# Copyright (c) Microsoft Corporation.All rights reserved.This# script is made available to you without any express, implied or# statutory warranty, not even the implied warranty of# merchantability or fitness for a particular purpose, or the# warranty of title or non-infringement.The entire risk of the# use or the results from the use of this script remains with you.##################################################################### Summary of Virtual Machine Manager Server####################################################################$SummaryDate = Get-Date# Substitute the name of your VMM server and domain in this command:$VMMServer = Get-VMMServer -ComputerName "VMMServer1.Contoso.com"$VMHosts = @(Get-VMHost)$HostedVMs = @(Get-VM | where {$_.Status -ne "Stored"})Write-Host "`nVIRTUAL MACHINE MANAGER SERVER" -ForegroundColor YellowWrite-Host "Summary Date :", $SummaryDateWrite-Host "VMM Server Name :", $VMMServer.NameWrite-Host "Evaluation Version :", $VMMServer.IsEvaluationVersionWrite-Host "Placement Goal :", $VMMServer.PlacementGoalWrite-Host "Total Hosts :", $VMHosts.CountWrite-Host "Hosted VMs :", $HostedVMs
[ Pobierz całość w formacie PDF ]