VMware Powershell Competition

I was wondering whether to enter the VMware Powershell competition or not, Looking at the prizes its a no brainer, how cool would it be to go to Vegas for VMworld 2008 ?!, but as you can see from my scripts on this site so far, they are no prize winners.  This is mainly because I am still relatively new to Powershell and still trying to grasp some of the concepts.

So anyway, I thought, what better way to grasp the concepts than to work towards something, so I have decided to work on my script and see how it goes, if it turns out ok then I may enter the comp just for the fun of it, although I'm sure there will be some master PS creators writing some amazing stuff.

So what am I working on ?

I'm working on something that will certainly be quite useful for myself and hopefully others... A VMware reporting script.

This will basically pull out all the config and details of things like your VMs, Hosts, Datastores, Clusters, Networks etc and put them directly into a nicely formatted Word document, I may even through in a few graphs for good measure to show top 10 Utilised VM's and hosts, maybee a few pie charts to show how much room is left on the datastores ?!

If you think this is a good idea please let me know, just so I know I am not wasting my time ! and if you can think of anything else to put in there also please let me know - all ideas appreciated.

Reported Update 2 Issues (HA)

A few of the forums and other blogs are reporting Problems with Update 2 HA....

Usual issues include:

“insufficient resources to satisfy HA failover level on cluster” and also “unable to contact a primary HA agent in cluster”

The following should help you out:

All hostnames need to be in lower case only.

In Virtualcenter check the following:

  • On each host in the cluster, go to the configuration tab, DNS and routing, hostname, everything needs to be lowercase

On each one of your ESX hosts:

ssh into each host and check lower case names only

  • /etc/hosts lowercase names only
  • /etc/sysconfig/network
  • cat /proc/sys/kernel/hostname if not correct :

hostname <FQDN>

  • after this you can check the settings are correct using

    uname -n

    hostname -a

    hostname -s

    hostname -d

    hostname -f

    hostname


  • make sure hostname in /etc/vmware/esx.conf is lowercase

    /adv/Misc/HostName = <FQDN in lowercase>

    Once these are checked enable HA on cluster again and cross your fingers.

Run ESXi 3.5 Update 2 from a USB drive

If you would like to check out ESXi 3.5 update 2 risk free without installing over the top of your current OS. Here’s a good pdf about how to install it on a USB drive.

Shame mine broke last week and I'm waiting for a new one in the post !

Sneak Preview Capacity Bottleneck Analyzer - Version 2.0

VKernel intrepid Founder and CEO Alex Bakman just couldn't wait to start talking about a future product release, VKernel's Capacity Bottleneck Analyzer V2.0. Needless to say, there brand new VP of Sales wasn't too happy about leaking news for a future product. But the cat's out of the bag. You can watch a video podcast that previews this latest release here

I wonder if there will be a UK version (Analyser) :)

Worth a listen...

Jonathan Walz & Hal Rottenberg, the guys behind the PowerScripting Podcast have a great show lined up for you.  They have been talking to Carter Shanklin from VMware about the PowerShell Toolkit

Carter has some exciting NEW news.

They also bring you news, resources, tips and whatever else they can scrape up.

ESXi Single Server Environment training just £27.50

Gain the knowledge and skills to operate VMware ESXi in a single-server environment.

This self-paced course contains brief concept modules, guided demos, and interactive simulations. Topics covered include: Virtualization Concepts, Server Configuration, Virtual Machine Management, Networking, Performance Monitoring, and more.

This online course includes approximately 120 minutes of content with unlimited access by the subscribing individual for 90 days:

After completing this course you will be able to:

  • Configure ESXi
  • Install the Virtual Infrastructure client
  • Understand and configure ESXi networking
  • Understand and configure ESXi storage
  • Monitor and configure resource use
  • Build and configure virtual machines and install guest operating systems
  • Clone virtual machines
  • Monitor and manage virtual machine performance

Click here to visit the VMware training site

Enhanced Vmotion

I was just reading up a little more on Enhanced Vmotion as was impressed that we no longer have to worry about CPU architecture and found the following useful information:

Enhanced VMotion Compatibility

Because new features are constantly incorporated into new CPUs, you are likely to encounter incompatibilities and therefore face problems while attempting migration with VMotion. Such CPU incompatibilities limit VMotion to a certain range of CPUs. VMware has investigated the issues and concluded that there is no software‐only solution to this problem. To minimize exacerbation of the compatibility problem with time, VMware has worked with CPU vendors to facilitate live migration of virtual machines across different CPU revisions.


VMware Enhanced VMotion Compatibility (EVC)—available in VMware Infrastructure 3 beginning with version 3.5 Update 2—facilitates VMotion between different CPU generations, taking advantage of Intel Flex Migration and AMD‐V Extended Migration technologies. When enabled for a cluster, EVC ensures that all CPUs within the cluster are VMotion compatible. CPUs starting with Intel 45nm Core 2 (Penryn) and AMD Second Generation Opteron (revision E or F) incorporate FlexMigration and Extended Migration technologies, respectively.


The EVC feature allows the virtualization layer to mask or hide certain features by modifying the semantics of the CPUID instruction and hides certain CPUID feature bits, even from nonprivileged code. For example, with support from hardware, the virtualization layer modifies the semantics of the CPUID instruction to mask or hide the SSE4.1 feature from any code (privileged or nonprivileged) to make CPUs differing in this feature compatible for VMotion.

Specifics on CPU compatibility with the Enhanced VMotion Compatibility feature are available in the Basic System Administration guide for each ESX release starting with version 3.5 Update 2.


EVC utilizes hardware support to modify the semantics of the CPUID instruction only. It does not disable the feature itself. For example, if an attempt to disable SSE4.1 is made by applying the appropriate masks to a CPU that has these features, this feature bit indicates SSE4.1 is not available to the guest or the application, but the feature and the SSE4.1 instructions themselves (such as PTESE and PMULLD) are still available for use. This implies applications that do not use the CPUID instruction to determine the list of supported features, but use try‐catch undefined instructions (#UD) instead, can still detect the existence of this feature.


Therefore, for EVC to be useful, application developers must adhere to recommended guidelines on feature detection. CPU vendors recommend that software programmers query CPUID prior to using special instructions and features available on their CPUs. If this guideline is followed by programmers, EVC is a reliable mechanism for live migration of x86 virtual machines across varied hardware. Thus, you can use EVC to enable an entire cluster to use the same set of basic features, allowing migration with VMotion across any two nodes in the cluster. VirtualCenter can also set up new hardware add‐ons to the cluster and apply these masks.

Conclusion
Virtualization is still a relatively new technological innovation, and the area of live migration of virtual machines is still in its infancy. VMware VMotion is an extremely useful and critical feature in data centers to ensure business continuity, resource optimization, and a host of other benefits. VirtualCenter performs numerous compatibility checks before allowing migration with VMotion. Some stringent CPU compatibility checks for VMotion are necessary for proper functioning of a virtual machine after migration. Though users can override these checks and complete VMotion by applying appropriate masks, the virtual machines and applications may not function properly if they rely on features particular to the underlying hardware. The x86
CPU vendors did not initially envision live migration of virtual machines and design CPUs to support it.

VMware has worked with CPU vendors to support such features, taking advantage of Intel Flex Migration and AMD‐V Extended Migration technologies. With Enhanced VMotion Compatibility, VMware Infrastructure works in conjunction with hardware to support live migration of virtual machines in a wider range of environments. Effective use of enhanced VMotion also depends on using application software that follows recommended guidelines to support CPU feature detection.

ESX3i Now Free

ESXi 3.5 Update 2 is now free, pick up a licence for free . Just login, fill out the questions and receive a free license.

ESX 3.5 Update 2 now available

VMware just released Update 2 for ESX(i) 3.5 and some new patches.

So what’s new?

  • Windows Server 2008 support – Windows Server 2008 (Standard, Enterprise, and Datacenter editions) is supported as a guest operating system. With VMware’s memory overcommit technology and the reliability of ESX, virtual machine density can be maximized with this new guest operating system to achieve the highest degree of ROI. Guest operating system customizations and Microsoft Cluster Server (MSCS) are not supported with Windows Server 2008.
  • Enhanced VMotion Compatibility – Enhanced VMotion compatibility (EVC) simplifies VMotion compatibility issues across CPU generations by automatically configuring server CPUs with Intel FlexMigration or AMD-V Extended Migration technologies to be compatible with older servers. Once EVC is enabled for a cluster in the VirtualCenter inventory, all hosts in that cluster are configured to ensure CPU compatibility for VMotion. VirtualCenter will not permit the addition of hosts which cannot be automatically configured to be compatible with those already in the EVC cluster.
  • Storage VMotion – Storage VMotion from a FC/iSCSI datastore to another FC/iSCSI datastore is supported. This support is extended on ESX/ESXi 3.5 Update 1 as well.
  • VSS quiescing support – When creating quiesced snapshot of Windows Server 2003 guests, both filesystem and application quiescing are supported. With Windows Server 2008 guests, only filesystem quiescing is supported. For more information, see the Virtual Machine Backup Guide and the VMware Consolidated Backup 1.5 Release Notes.
  • Hot Virtual Extend Support – The ability to extend a virtual disk while virtual machines are running is provided. Hot extend is supported for vmfs flat virtual disks without snapshots opened in persistent mode.
  • 192 vCPUs per host – VMware now supports increasing the maximum number of vCPUs per host 192 given that the maximum number of Virtual Machines per host is 170 and that no more than 3 virtual floppy devices or virtual CDROM devices are configured on the host at any given time. This support is extended on ESX 3.5 Update 1 as well.

Hardware additions:

  • 8Gb Fiber Channel HBAs – Support is available for 8Gb fiber channel HBAs. See the I/O Compatibility Guide for ESX Server 3.5 and ESX Server 3i for details.
  • SAS arrays – more configurations are supported.  See the Storage/SAN Compatibility Guide for ESX Server 3.5 and ESX Server 3i for details.
  • 10 GbE iSCSI initiator – iSCSI over a 10GbE interface is supported. This support is extended on ESX Server 3.5 Update 1, ESX Server version 3.5 Update 1 Embedded and ESX Server version 3.5 Update 1 Installable as well.
  • 10 GbE NFS support – NFS over a 10GbE interface is supported.
  • IBM System x3950 M2 – x3950 M2 in a 4-chassis configuration is supported, complete with hardware management capabilities through multi-node Intelligent Platform Management Interface (IPMI) driver and provider. Systems with up to 32 cores are fully supported.  Systems with more than 32 cores are supported experimentally.
  • IPMI OEM extension support – Execution of IPMI OEM extension commands is supported.
  • System health monitoring through CIM providers - More Common Information Model (CIM) providers are added for enhanced hardware monitoring, including storage management providers provided by QLogic and Emulex.  LSI MegaRAID providers are also included and are supported experimentally.
  • CIM SMASH/Server Management API – The VMware CIM SMASH/Server Management API provides an interface for developers building CIM-compliant applications to monitor and manage the health of systems.  CIM SMASH is now a fully supported interface on ESX Server 3.5 and VMware ESX Server 3i.
  • Display of system health information – More system health information is displayed in VI Client for both ESX Server 3.5 and VMware ESX Server 3i.
  • Remote CLI – Remote Command Line Interface (CLI) is now supported on ESX Server 3.5 as well as ESX Server 3i. See the Remote Command-Line Interface Installation and Reference Guide for more information.
  • VMware High Availability - VirtualCenter 2.5 update 2 adds full support for monitoring individual virtual machine failures based on VMware tools heartbeats. This release also extends support for clusters containing mixed combinations of ESX and ESXi hosts, and minimizes previous configuration dependencies on DNS.
  • VirtualCenter Alarms - VirtualCenter 2.5 Update 2 extends support for alarms on the overall health of the server by considering the health of each of the individual system components such as memory and power supplies. Alarms can now be configured to trigger when host health degrades.
  • Guided Consolidation - now provides administrators with the ability to filter the list of discovered systems by computer name, IP address, domain name or analyzing status. Administrators can also choose to explicitly add physical hosts for analysis, without waiting for systems to be auto-discovered by the Consolidation wizard. Systems can be manually added for analysis by specifying either a hostname or IP address. Multiple hostnames or IP addresses, separated by comma or semi-colon delimiters, may also be specified for analysis. Systems can also be manually added for analysis by specifying an IP address range or by importing a file containing a list of hostnames or IP addresses that need to be analyzed for consolidation. Guided Consolidation also allows administrators to override the provided recommendations and manually invoke the conversion wizard.
  • Live Cloning - VirtualCenter 2.5 Update 2 provides the ability of creating a clone of a powered-on virtual machine without any downtime to the running virtual machine. Therefore, administrators are no longer required to power off a virtual machine in order to create a clone of it.
  • Single Sign-On - You can now automatically authenticate to VirtualCenter using your current Windows domain login credentials on the local workstation, as long as the credentials are valid on the VirtualCenter server. This capability also supports logging in to Windows using Certificates and Smartcards. It can be used with the VI Client or the VI Remote CLI to ensure that scripts written using the VI Toolkits can take advantage of the Windows credentials of your current session to automatically connect to VirtualCenter.

Download updates now:

ESX 3.5 Update 2
ESXi 3.5 installable Update 2

VirtualCenter 2.5 Update 2

VMware Consolidated Backup 1.5

[Original Source - Yellow Bricks]

Quick Stats from VMware for reports

I wrote another quick script today as my powershell skills grow!

The following script can be used to give you a JPG outputted graph of some stats that you can choose, handy for reports.

It can easily be adjusted to perform stats on the ESX servers (vmhost) as well.

Example output (My Test server names have been blurred):

Chart

connect-VIServer yourserver

# Set the following 3 variables for your needs
# Example stats are:
# % CPU Usage - cpu.usage.average
# Mhz CPU Usage - cpu.usageMHZ.average
# % Memory Usage - mem.usage.average
# Kbps Network Usage - net.usage.average
# Kbps Disk Usage - disk.usage.average

$Caption = "CPU Usage"
$Stat = "cpu.usage.average"
$NumToReturn = 20

$categories = @()
$values = @()
$chart = new-object -com OWC11.ChartSpace.11
$chart.Clear()
$c = $chart.charts.Add(0)
$c.Type = 4
$c.HasTitle = "True"
$series = ([array] $chart.charts)[0].SeriesCollection.Add(0)

Get-Stat -Entity (Get-vm) -Stat $stat -MaxSamples 1 -Realtime |Sort-Object Value -Descending | Select-Object Entity, Value -First $NumToReturn | foreach-object {

$categories += $_.Entity.Name
$values += $_.Value * 1
}
$series.Caption = $Caption
$series.SetData(1, -1, $categories)
$series.SetData(2, -1, $values)
$filename = (resolve-path .).Path + "\Chart.jpg"
$chart.ExportPicture($filename, "jpg", 800, 500)
invoke-item $filename

VMware Infrastructure (VI) Toolkit (for Windows) 1.0

Check the following site for the full version of the VI toolkit which has been in beta for sometime. 

This is apparently released this weekend but already available by following the breadcrumbs....

http://www.ntpro.nl/blog/archives/549-Carter-Shanklin-about-the-GA-of-the-VI-Toolkit.html

Powershell Repository

Looking for a piece of powershell code to do something, look no further, there are some great examples here... http://poshcode.org/

ESXi Free from 28 July

Today, VMware is taking another step towards making virtualisation ubiquitous by announcing that VMware ESXi will be available for download at no cost as of the week of July 28, 2008.

VMware has always believed that virtualisation needs to be ubiquitous. Since 2001, VMware has provided the industry's most popular and reliable hypervisor used by more than 100,000 customers. During this evolution, partners like you have been critical in educating and delivering virtualisation to customers of all sizes. In December 2007, VMware announced significant improvements with ESXi - its third-generation, stand-alone hypervisor. With its smaller footprint and OS-independence, ESXi ensures even higher levels of security and reliability while making virtualisation easier than ever to deploy.

More info can be found here http://www.chriswolf.com/?p=175

Give the users a console again

Granting Console Access and Power On/Off functions to your Users

Sometimes a user will complain that they need console access to there servers or permission to turn on/off or reset there machines if there is a problem, as the servers become virtualised this can be achieved in a number of ways, I have documented a couple of these ways below…

  1. Apply the correct permissions for the user you wish to access the virtual machine limiting them to there required security permissions.

If you're using VirtualCenter, you can use roles and groups to assign permission to users such that they would only see the VM’s that they have permission to and could have various levels of rights over those VM’s. This is covered in depth starting at page 261 here - http://www.vmware.com/pdf/vi3_35/esx_3/r35/vi3_35_25_admin_guide.pdf.

You could do something similar with ESX 3.0.x but that was removed with ESX 3.5.

With ESX 3.5 you can create individual users, but you can't grant permissions to specific VM’s without VirtualCenter.

  1. Once you have completed the permissions side of things start your favourite web browser and browse to your VC or ESX server web interface by using https://yourservername/ui

clip_image002

  1. Log into the web interface using your own Administrator account details, we will use this to create the link which you will be providing to the end user.
  1. clip_image004

    Use the navigation bar (blue area) on the left hand side of the screen to navigate to and click on the Virtual Machine you wish to give access to

  1. clip_image006

    Click the “Generate Remote Console URL” on the right hand side of the screen

  1. clip_image008

    Use this form to customise what you would like the user to see.

  1. Once completed you can copy the link from the light blue area and send this to the user.

There is also a dedicated client for accessing machines on the VC/ESX servers which also works very well, this can be downloaded from the following area: http://www.ntpro.nl/blog/archives/170-The-games-have-begun.html

clip_image010

Exchange/Sharepoint - Why go physical ?

Found an interesting article at this blog talking about Sharepoint and also Exchange 2007 running on VMware, after reading this why would you go physical ?

Free Citrix Monitoring

A new simple free product has been released which will monitor your Citrix farm and include some of the following features:

-detailed logging
-dashboard overview
-alert siren
-manual override for license server/datastore
-flexible configuration options
-maintenance mode for servers
-send email on alert
-specially designed for Citrix

Download it here

Microsoft Office Visio 2007 Professional Add-In for Rack Server Virtualisation (Virtual Rack)

This free Microsoft download called the "Rack Server Virtualisation Add-in" provides the capability to pull the rack-server data either from an Excel spread sheet or from the user and render the Visio diagram.

With over 70% of server hardware being under-utilized, this very valuable tool can draw a clear picture of your hardware utilization. This tool auto-generates the diagram of your rack and provides clear server details from a linked Excel template. Analyse your racks and servers using WMI or get the utilization data over time using the Operations Manager connection. Microsoft Visio 2007 Add-In for Rack Server Virtualisation (Virtual Rack) uses various new features of Visio 2007 to display the details of servers, racks and colours present in the Data Centre. This add-in enables consolidation of physical servers by allowing many virtual servers to run concurrently on one physical server results in improvement of system utilization, reduction in number of physical servers, lowering costs, increasing flexibility etc.

The Visio 2007 Add-In provides users a virtualisation picture in addition to the existing picture of the rack based on some parameters to compare the power consumption and space saving before and after consolidation. Use the virtualisation button to see the before and after detailed diagram of your racks. See clearly where you have the opportunity to save on space and power.

Download the Microsoft Office Visio 2007 Professional Add-In for Rack Server Virtualisation (Virtual Rack).

Installing Hyper-V on Windows Server 2008, Server Core

There is a very nice step by step guide here....

http://blog.avanadeadvisor.com/blogs/waynea/archive/2008/07/05/11433.aspx

Time to dual boot the home PC and start playing I think :)

VMware Server 2.0 Release Candidate 1

This newest version offers the capabilities from before, plus an array of new features, increased performance and stability—including a broader range of guest operating system support, direct access to virtual machine consoles, an intuitive Web-based management interface, and increased memory for greater scalability. With over 3 million downloads worldwide, VMware Server continues to innovate to provide users with a superior introductory experience to virtualization—for free.

What's New

* Volume Shadow Copy Service (VSS): Properly backup the state of the Windows virtual machines when using the snapshot feature to maintain data integrity of the applications running inside the virtual machine.

* Virtual Machine Communication Interface (VMCI): Support for fast and efficient communication between a virtual machine and the host operating system and between two or more virtual machines on the same host.

* Support for SCSI pass-through (generic) devices: Allows for SCSI devices such as tape backup devices to be connected to virtual machines.

* Expand disk capacity on the fly: Allows for adding new SCSI hard disks and controllers to a running virtual machine.

* Firefox 3 as a supported browser for the management interface.

Download it here

7 side effects of sloppy virtualization

ORLANDO -- IT professionals may initially be awestruck by the promises of virtualization, but Gartner analysts warn that awe could turn into upset when organizations start to suffer from seven nasty side effects.
David Coyle, research vice president at Gartner, detailed the seven side effects at the research firm's Infrastructure, Operations and Management Summit, which drew nearly 900 attendees. While virtualization promises to solve issues such as underutilization, high hardware costs and poor system availability, the benefits come only when the technology is applied with proper care and consistently monitored for change, Coyle explained.

Here are the reasons Gartner says virtualization is no IT cure-all:

1. Magnified failures. In the physical world, a server hardware failure typically would mean one server failed and backup servers would step in to prevent downtime. In the virtual world, depending on the number of virtual machines residing on a physical box, a hardware failure could impact multiple virtual servers and the applications they host.

"Failures will have a much larger impact, effecting multiple operating systems, multiple applications and those little tiny fires will turn into big fires fast," Coyle said.

2. Degraded performance. Companies looking to ensure top performance of critical applications often dedicate server, network and storage resources for those applications, segmenting them from other traffic to ensure they get the resources they need. With virtualization, sharing resources that can be automatically allocated on demand is the goal in a dynamic environment. At any given time, performance of an application could degrade, perhaps not to a failure, but slower than desired.

3. Obsolete skills. IT might not realize the skill sets it has in-house won't apply to a large virtualized production environment until they have it live. The skills needed to manage virtual environments should span all levels of support, including service desk operators who may be fielding calls regarding their virtual PCs. Companies will feel a bit of a talent shortage when moving toward more virtualized systems, and Coyle recommends starting the training now.
"Virtualized environments require enhanced skill sets, and virtual training across many disciplines," he said.

4. Complex root cause analysis. Virtual machines move -- that is the part of their appeal. But as Coyle pointed out, it is also a potential issue when managing problems. Server problems in the past could be limited to one box, but now the problem can move with the virtual machine and lull IT staff into a false sense of security.

"Is the problem fixed or did you just lose it? You can't tell in a virtual environment," Coyle said. "Are you just transferring the problem around from virtual server to virtual server?"

5. No standardization. Tools and processes used to address the physical environment can't be directly applied to the virtual world, so many IT shops will have to think about standardizing how they address issues in the virtual environment.
"Mature tools and processes must be revamped," Coyle said.

6. Virtual machine sprawl. The most documented side effect to date, virtual server sprawl results from the combination of ease of deployment and lack of life-cycle management of virtual machines. The issue could cause consolidation efforts to go awry when more virtual machines crop up than there are server administrators to manage them.
"The virtualized environment is in constant flux," he said.

7. May be habit forming. Once IT organizations start to use virtualization, they can't stop themselves, Coyle said. He offered tips to help curb the damage done from giving into a virtual addition.

"Start small. Map dependencies. Create strong change processes. Update runbooks. Invest in capacity management tools. And test, test, test," he said.

Original : Network World

More Powershell

I have now updated my first powershell script, this enables you to open a pre-configured spreadsheet with graphs and fill in the cells needed to populate the graphs and produce a nice 2 minute report on the state of the infrastructure, this is currently customised to my particular clusters but can be easily modified...

For a copy of the spreadsheet drop me a mail or a comment on this post.

Get-VIServer yourservername

$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Open("C:\Resource.xls")
$Sheet = $Excel.WorkSheets.Item(2)

$intRow = 11
$colItems = Get-Datastore | Select-Object -property "Name","FreeSpaceMB","CapacityMB" | Sort-Object Name
$totalcapacity = 0

foreach ($objItem in $colItems)
{
    $Sheet.Cells.Item($intRow,2) = $objItem.Name
$used = $objItem.CapacityMB - $objItem.FreeSpaceMB
$Sheet.Cells.Item($intRow,3) = $used
$totalcapacity = $totalcapacity + $objItem.CapacityMB

$intRow = $intRow + 1

}
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(5,4) = $totalcapacity

$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(4,3) = "Done"
$Sheet = $Excel.WorkSheets.Item(1)

$intRow = 17
foreach ($objItem in $colItems)
{
    $Sheet.Cells.Item($intRow,2) = $objItem.Name
$Sheet.Cells.Item($intRow,3) = $objItem.CapacityMB

$intRow = $intRow + 1

}

$totalmem = 0
$cpumhz = 0
$totalcpu = 0

Get-VMHost | %{Get-View $_.ID} | %{
$esx = "" | select NumCpuCores, Hz, Memory
$esx.NumCpuCores = $_.Hardware.CpuInfo.NumCpuCores
$esx.Hz = $_.Hardware.CpuInfo.Hz
$esx.Memory = $_.Hardware.MemorySize
 
$totalmem = $totalmem + $esx.Memory
$cpumhz = $esx.numCpuCores * $esx.Hz
$totalcpu = $totalcpu + $cpumhz
}
$formatedmem = ($totalmem /1024) /1024
$formatedcpu = ($totalcpu /1000) /1000
 
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(6,4) = $formatedmem
$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(5,3) = "Done"
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(7,4) = $formatedcpu
$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(6,3) = "Done"

$Sheet = $Excel.WorkSheets.Item(2)
$colItems = Get-Stat -Entity (Get-ResourcePool -Name "Live") -Stat cpu.usagemhz.average -MaxSamples 1 -Realtime
foreach ($objItem in $colItems)
{
    $Sheet.Cells.Item(4,4) = $objItem.Value
}

$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(7,3) = "Done"
$Sheet = $Excel.WorkSheets.Item(2)

$colItems = Get-Stat -Entity (Get-ResourcePool -Name "Test") -Stat cpu.usagemhz.average -MaxSamples 1 -Realtime
foreach ($objItem in $colItems)
{
    $Sheet.Cells.Item(5,4) = $objItem.Value
}
$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(8,3) = "Done"
$Sheet = $Excel.WorkSheets.Item(2)
$colItems = Get-Stat -Entity (Get-ResourcePool -Name "Live") -Stat mem.active.average -MaxSamples 1 -Realtime
foreach ($objItem in $colItems)
{
    $promem = ($objItem.Value /1000)
$Sheet.Cells.Item(4,3) = $promem
}

$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(9,3) = "Done"
$Sheet = $Excel.WorkSheets.Item(2)
$colItems = Get-Stat -Entity (Get-ResourcePool -Name "Test") -Stat mem.active.average -MaxSamples 1 -Realtime
foreach ($objItem in $colItems)
{
    $nonpromem = ($objItem.Value /1000)
$Sheet.Cells.Item(5,3) = $nonpromem
}
$Sheet = $Excel.WorkSheets.Item(3)
$Sheet.Cells.Item(10,3) = "Done"
$Sheet.Cells.Item(13,3) = "Done"