Automate the VMs using PowerCLI performance report

Dear Experts,

I want to automate the monthly performance report (CPU, memory, disk) of the Virtual Machines using PowerCLI or any other script. Basically, I want to do under the tasks mentioned on monthly basis:

1. use of the CPU (of all virtual machines) statistical average based monthly (as a percentage). Same report for memory (in percent) and the disc (Kbps).

2. is it possible folderwise? I have several clients in my support infrastructure and I made segregation in making records and for each of them, this report is necessary.

3. export only these 3 reports in Excel.

Details of the infrastructure: ESXi 4.0 and 4.1

Dear Experts, your kind suggestions will be much appreciated? As it takes a lot of time as we do this manually.

Thank you very much!

No problem, with the Group-Object cmdlet we can divide the result by VM.

$metrics = "cpu.usage.average","mem.usage.average","disk.usage.average"
$start = (Get-Date).AddDays(-30)

$folders = Get-Folder -Location (Get-Folder -Name vm -Location Datacenters)
# $folders = Get-Folder -Name Folder1,Folder2,Folder3
&{foreach($folder in $folders){
    $vms = Get-VM -Location $folder    if($vms){
      $stats = Get-Stat -Entity $vms -Stat $metrics -Start $start -ErrorAction SilentlyContinue      if($stats){
        $stats | Group-Object -Property {$_.Entity.Name} | %{
          New-Object PSObject -Property @{
            Folder = $folder.Name            VM = $_.Values[0]
            CpuAvg = ($_.Group | where {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property Value -Average).Average            MemAvg = ($_.Group | where {$_.MetricId -eq "mem.usage.average"} | Measure-Object -Property Value -Average).Average            DiskAvg = ($_.Group | where {$_.MetricId -eq "disk.usage.average"} | Measure-Object -Property Value -Average).Average          }
        }
      }
    }
  }} | Export-Csv C:\report.csv -NoTypeInformation -UseCulture

Tags: VMware

Similar Questions

  • automate the smartlist using contour utility questions

    Hello

    IAM want to automate the smartlist using .csv for Member of the entity dimension using contour utility

    Create a smart list called "alnasser' member of the dimension entity E10134

    alnesser smarlist contains a) price b) sale c) prefixing sale d) d afterpricing) test factor has two child

    IAM not not see members of the smart list under alnasser

    file source as follows below

    Entity, Parent, Data Storage, Description, Data Type, Base, Plan Type (Plan1), aggregation (Plan1), Smart List ALNASSER currency
    E10134, store, ALNASSER, unspecified, USD, 1, +, ALNASSER, sales

    his show a column name or header not recognized

    How to give the source smart list with the entity dimension and where I did the source of error and give to testfactor

    I guess that the error with the header name alnasser smartlist

    Sreekumar.H

    Hello

    Could you just add the values for the smart list in the planning, once they are in place, you don't have to set them up again.
    If you can't then I would use something like LCM to create an XML with values inside and then import it into.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • How to use PowerCLI to report on the parameters of VMware Tools?

    Anyone know what the script would be to report on the configuration of the VMware Tools on a virtual computer running?  What I'm really interested by creates a report telling me if VMware Tools is configured to synchronize the time with the host.

    Thank you!

    To see what comments to synchronize their time with the host country, you can use this script

    foreach($vm in Get-VM){
         $row = "" | Select Name, ServerTimeSync
         $row.Name = $vm.Name
         $row.ServerTimeSync = $vm.ExtensionData.Config.Tools.SyncTimeWithHost
         $row
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Save the customized using MS Office report Express VI filename

    When my program creates a report, I want to save it as a serial number, defined in the report.  I want to use MS Office report Express VI to do this, but unfortunately it only allows you to save the file name as time and/or incremental number.

    Hi jliu317,

    In the meantime that warn you the moderator to move your thread, here is my solution. (Correct me if I'm wrong)

    In MS Office Report, there is a block diagram entry named path to save the report. That is where you can save your report in Word (.doc) or Excel (.xls) under the name of file custom as serial number, as shown below.

    http://zone.NI.com/reference/en-XX/help/370274G-01/lvoffice/ms_office_report/

    I hope this helps.

    EE - Lim-

  • How to read the content .vmtx of the file using PowerCLI

    Hi all

    I have a virtual computer model in one of the NFS attached to my ESX host data stores.
    I need to get the display name and some other details of the vmtx this model file.
    Any method to get values from vmtx file using PowerCLI... ?

    Thank you in advace for all help.

    Hello, MattGeorgey-

    One way you could do this would be to use the Copy-DatastoreItem cmdlet to retrieve the .vmtx file, and then you can read it, Get-Content on it, etc., as you please.  Something like:

    ## copy the VMTX file from the datastore to a local spotCopy-DatastoreItem vmstore:\MyDatacenterName\my_datastore_name\myTemplate\myTemplate.vmtx C:\temp\.
    
    ## get the contents of the VMTX file$colVMTXContents = gc C:\Temp\myTemplate.vmtx## get the line that contains the "displayName" value$colVMTXContents | Select-String displayName
    

    And, you can access some of the elements that are specified in the file .vmtx using the property Config.ExtraConfig of the display of the model as object:

    ## get the template object$tmplMyTemplate = Get-Template myTemplate## get a particular value for an ExtraConfig item$tmplMyTemplate.ExtensionData.Config.ExtraConfig | ?{$_.Key -eq "nvram"}
    

    How do I?

  • How to - migrate VM through the vCenters using PowerCLI - bypass the validation of network

    Hello

    I'm working on an automation project, which requires that we have a VM of 1 vCenter to another.
    Each vCenter is a stand-alone instance, they are not related.

    The problem we have is that cmdlets Import-vAPP and export-VAPP are 'too' data validation.

    VAPP export works very well, however, our problems are on the part of import-vapp.

    Each vCenter uses a distributed switch, so when we run this command, we get the below error

    Import-vApp -VMHost $targetEsxhost -Source $importpath -Name $hostname -Datastore $targetDatastore -Location $targetCluster -DiskStorageFormat "THICK" -Force -ErrorAction Stop
    

    Import-TIME: 28/03/2016-09:18:29 Import-TIME host lacked any defined virtual network.

    Online: 8 char: 1

    I'm guessing that the import fails because the switches names and IDs are different on the target as on the source vCenter vCenter

    We use vCenter 5.1 and 5.5 PowerCLI for execution of our automation tools.

    What other options do I import to be successful, somehow bypassing validation of network?

    We can reconfigure our VM subsequently, but we want to just that import of fill.

    Is there any other cmdlets, that we can use, or go on the road to the API and something like Onyx allows you to spy on the vSphere Client to "make our own import-function"?

    All I know, you cannot ignore the validation, but you might take away the network.

    What I mean, check out the network configuration and store it outdoors, then try to remove the adapters for virtual machines.

    Now you should be able to migrate the virtual computer.

    During the migration, restore the vNIC and from the saved data, you have the network configuration.

  • Unable to see the rate of disk on the VMS using NFS

    I think I know the root of the problem... it's because in vCenter, it isn't follow rates disk VMDK on NFS with the metric of the standard rate of disk.  vCenter actually uses the 'rate of virtual disk' instead.  But it seems that all default counters for vFoglight aren't looking 'Rate of virtual disk' but 'Rate of disc' so that all my virtual machines with no available data trying to determine their rate of disk.

    Is there anyway to change this behavior?

    There are some conditions in order to obtain metrics NFS:

    • vSphere 4.1 and later versions
    • vFoglight 6.6 and FGLAM base VMware agent
    • Metric NFS does not appear on the dashboard by default, only exposed in the dashboard customized by drag / move.
      • This will change in a future release.

    I Don t have any NFS data warehouses in my lab so I can´t show you a dashboard example with action of NFS. If I get my hands on a laboratory with NFS I'll post back a few screenshots here.

    / Mattias

  • Script display the VMS using RDM

    How can I create a list of all the virtual machine using physical RDM Mode, and what a ESXi host, they are on?

    Thank you

    Hello again-

    There are of course - you could do a calculated property to grasp that, like:

    Get-VM | ?{Get-HardDisk -VM $_ -DiskType RawPhysical} | Select Name,VMHost, @{n="ownerPerCustAttr"; e={($_.CustomFields | ?{$_.Key -eq "owner"}).Value}}
    

    Enjoy.

  • Example damper performance report does not properly

    Hello

    I have a problem in the use of edit cell.vi-Word to manipulate several cells in a table to a word document. That makes this vi on my system is to insert the values of the first column in all other columns. See the example for damper Performance report. If I run this report, all values are identical to the first column which I think is not the behavior of this example.

    Don't you see the same behavior or is only on my system?

    I use Word 2010 LV 2013

    best regrads

    URS

    I found the solution through the Solution of the wire and the response of Thoric.

    There seems to be a problem with word 2010.

    You will find the same for loops in "Word_update_table.vi".

    Attached is the vi changed.

  • Need help to report on the configurations of the virtual machine using PowerCLI

    Hi guys,.

    I try to shoot down vCenter virtual computer configuration details and am not having much luck with vCPU multicore machines.

    Looking at the lists of VMS in vSphere Client, it offers a column "Number of CPU" basis and does not include any other granularity (i.e. in terms of casings & carrots as opposed to simply 'CPU Count').

    I thought that maybe I have better luck using PowerCLI and essentially, the cmdlet "Get - VM" has the kind of information I'm looking for, but I find that it lacks a bit when it comes to vCPU details.  Essentially, it turns out that does not do much better than the list of virtual machines in vSphere Client because it produces only a "CPU Num" value, which is not particularly useful.

    For example, if "processors Num" 4, that '4' means?  This could mean one of the following:

    • 1 x 4 drivers
    • Core 2 x 2
    • Basic 4 x 1

    I hope someone out there can help produce me a list of virtual machines with details of configuration that includes both sockets & carrots for vCPU?

    Thanks in advance!

    Try like this

    Get-VM | Select Name, @{N="CPU";E={$_.ExtensionData.Config.hardware.numCPU/$_.ExtensionData.Config.hardware.numCoresPerSocket}}, @{N="Core per CPU";E={$_.ExtensionData.Config.hardware.numCoresPerSocket}}
    
  • What are the tasks we can perform by using Component Services in the Microsoft Management Console?

    Original title: use MMC

    Can someone enlighten me on component services, found in the administrative tools, including the management console folder. Is their anything that can be done by someone who has no knowledge on this subject, extensive Windows, I use XP (SP3) thank you.

    Hi ratchet.

    Microsoft Management Console (MMC) lets system administrators create much more flexible user interfaces and customize administration tools.

    See this link for the tasks that we can perform using Component Services in the Microsoft Management console.

    With Component Services, administrators can deploy and administer service applications of components through a graphical user interface or automate administrative tasks using a programming or scripting language. Software developers can use Component Services to visually configure routine component and behavior of the application, such as security and participation in transactions, and to integrate components into Component Services applications.

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/snap_start_mmc.mspx?mfr=true

    Also check out this link:

    Using the Microsoft Management Console:

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/snap_start_mmc.mspx?mfr=true

  • Using PowerCLI to recover the capacity of volume comments data

    I am using PowerCLI to declare on the volume letter and free space associated with a guest computer.  I am currently addressing this problem through the extensiondata of the VM guest and then placing the properties I want in a PSObject.

    The question that I am running is that numeric values keep coming up as zero when it is inside the loop for, although they correctly resolve by themselves.  One thing I found interesting was these two upcoming properties like "System.Nullable [long"] when executing GetType(), but I don't know if that is related to the question.

    The script is below, and I changed the font color on the problem section.  I'd appreciate any help.

    # Pre - performance Variables

    $USCulture = New-Object - TypeName System.Globalization.CultureInfo - ArgumentList "en - us".

    $USCulture.NumberFormat.PercentDecimalDigits = 2

    $USCulture.NumberFormat.NumberDecimalDigits = 2

    Guest computers #Get

    [table] $vmguests = $vmcluster | Get - VM

    foreach ($vmguest to $vmguests)

    {

    $vmguestinfo = new-Object - TypeName System.Management.Automation.PSObject

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name "Hostname" - value $vmguest.extensiondata.guest.Hostname

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name "GuestState"-$vmguest.extensiondata.guest.GuestState value

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name 'GuestFullName'-$vmguest.extensiondata.guest.GuestFullName value

    $vmguesthdds = $vmguest. ExtensionData.Guest.Disk

    for ($i = 0; $i - lt $vmguesthdds. Length; $i++)

    {

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name ' DiskPath$ I '-$vmguesthdds [$i] value. DiskPath

    $vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' CapacityGB$ I "-value {($vmguesthdds [$i]. Capacity). ToString ("N", $USCulture)}

    $vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' UsedSpaceGB$ I "-value {[System.Decimal]: Subtract ($vmguesthdds [$i].} Capacity, $vmguesthdds [$i]. FreeSpace). ToString ("N", $USCulture)}

    $vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' FreeSpacePercent$ I "-value {[System.Decimal]: Divide ($vmguesthdds [$i].} FreeSpace), ($vmguesthdds [$i]. Capacity). ToString ("P", $USCulture)}

    }

    [table] $vmguestresults += $vmguestinfo

    }

    Thank you

    Yes, he had a few typos in the code.

    I corrected which, in the code and the attachment.

    Try this one.

    I'm afraid that I can't achieve this GitHub repository.

    A search on your GitHub account does not return either

  • Way to the commands per second using PowerCLI

    You can use powerCLI for average orders per second of a virtual machine on a historical period in the same way, as you can with cpu.usagemhz.average?

    Just to clarify:

    Does

    datastore.numberreadaveraged.Average

    give me information on the entire data store connected to the virtual machine? Or is information specific to just the VM I comment on?

    (In this case, I'm eager to get all the IOPs for all all of the virtual disks connected to a specific virtual machine)

    It gives you the IOPS / s specific to entire virtual machine and not the data store.

    Also - I'm the zeros for my data when I launch the present.  I see in vSphere client commands per second only to the data in real time, not for the last day, week or year.  Is it because of my level settings statistics?

    Yes, vCenter 5.0 and place unfortunately don't collect statistics of e/s long term on a per-VM level more.

    However, you can still add these values to return to lower levels of statistics as described in this article:

    http://alpacapowered.WordPress.com/2012/12/17/control-vCenter-performance-counter-collection-and-get-back-VM-IOPS-statistics/

  • Automatic creation of pools (linked Clone) using powerCLI

    Hello

    I am using powerCLI to create automatic pool (linked clone). I came across the following cmdlet in theVMware powershell integration white paper:

    Get-ViewVC - serverName < IP/domain FULL name >. Add-AutomaticLinkedClonePool-pool_id

    TestAutomaticLinkedClonePool - namePrefix pad - parentVMPath / < Center > < parentVM > /vm/

    -parentSnapshotPath / < cliché - > vmFolderPath / < Center > /vm - resourcePoolPath

    / /host/ < Center > < ESX > / resources - dataStoreSpecs / < Center > /host/ < ESX > / < datastore >

    -composer_ad_id < id ad composer >

    Now, I want to help discover (with an example will be very useful) how you specify and how find you each of the following (as what do I put after each other):

    -parentVMPath

    -parentSnapshotPath

    -vmFolderPath

    -resourcePoolPath

    -dataStoreSpecs

    -composer_ad_id

    Please give an example of each if possible.

    Thank you!

    OK, I'll give it a try.

    The parentVMPath parameter expects the path to the virtual machine that you want to spawn the pool (obviously).

    Such a path looks like this: / MyDC/vm/MyVM

    Where MyDC is the datacentername, the vm folder is hidden folder that contains the hierarchy of models and virtual computers, and finally the name of the virtual machine itself.

    If your master VM is deeper in the structure of folders, just add the folders in the path.

    Ex: / MyDC/vm/Folder1/Folder2/MyVM

    The parentSnapshotPath is similar to the previous setting, but obviously needs to point to the snapshot pool should clone.

    Alan has a nice feature to recover the snapshotpath Updateand re-view pools calm.

    The vmFolderPath is where the virtual machines that are created for the pool to be stored.

    Similar to the previous settings, but now for the record once again.

    Ex: / MyDC/vm/PoolFolder

    resourcePoolPath must point to a resourcepool.

    Such a path will look something like this: / MyDC/host/MyCluster/Resources/MyResourcePool

    Note that host and resources are again hidden folders!

    datastoreSpecs: this is not the most obvious.

    He wants the full path to a data store in a cluster that is specified by a resource pool.

    See the function VVGetDatastorePath to determine the paths to vSphere Datastore objects

    The composer_ad_id wants that the ID of the AD domain, in which the composer is a member server.

    You can get this through to: ComposerDomain-Get | select composer_ad_id


    As side note, take a look at the Integration of PowerShell with view 5.0 white paper. Perhaps, it is not intended for the latest version of the view

    but he explains some settings a lot better than I could

  • Is it possible to interact with the guest virtual computer console using PowerCLI?

    I'm trying to automate the installation of Linux on the ESXi systems.  Installing Linux is all from the command line.  Is there a way that I can interact with the console or shell comments VM using PowerCLI?

    In my view, customization works only with officially listed linux distributions.

    Kind regards

    Nedko Nedev

    PowerCLI development team

Maybe you are looking for