Reports on multiple virtual centers and export to CSV format

Everyone,

Does anyone know if possible a way for me to do the following in the following format.

Requirements:

(1) report on multiple virtual centers

(2) export results to CSV or Excel with a title between each virtual Center

(3) the need for Virtual Center Cluster belongs, name of the Cluster, host number of ESX and number of virtual machines. (Additional information can be added to the report later).

It would be not so hard if I could just connect and report on all virtual centers and my results to export in this way.  However, each virtual server Center have a different purpose and that is how senior management wants to see the results.

For example:

VC3 VC1 and VC2 = service server environment

VC4 and VC5 VC6 = service Workstation environments

VC7 VC8 = environment of Cloud Computing Services

What I would do is:

(1) connect to the first 3 virtual centers and collect the above information.

(2) I would like to create a title in the CSV or Excel named 'Standard Server environment summary'

(3) then I would like to export these 4 columns with data for each cluster.

Cluster is managed by this Virtual Center, the name of the Cluster, number # VM and ESX host

I then unplug the 3 first virtual centres.

Next

(1) I would like to connect to the 3 next virtual centres

2) add to the previous CSV or Excel with a title 'desktop environment summary.

(3) export the same information as above in the CSV file

Any help would be greatly appreciated.

Try something like this

$vcenters = @{}
$vcenters["Server Environment"] = @("VC1","VC2","VC3")
$vcenters["Workstation Environment"] = @("VC4","VC5","VC6")
$vcenters["Cloud Environment"] = @("VC7","VC8")

Set-PowerCLIConfiguration -DefaultVIServerMode Single -Confirm:$false | Out-Null
$vcenters.GetEnumerator() | %{
  &{foreach($vc in $_.Value){
      $currentvc = Connect-VIServer -Server $vc      Get-Cluster -Server $currentvc | %{
        New-Object PSObject -Property @{
          "Cluster is managed by VC" = $currentvc.Name          Cluster = $_.Name          "# of ESX hosts" = @($_.ExtensionData.Host).Count          "# of VM" = Get-View $_.ExtensionData.Host -Server $currentvc |          %{@($_.Vm).Count} |          Measure-Object -Sum |          Select -ExpandProperty Sum        }
      }
    }} | Select "Cluster is managed by VC",Cluster,"# of ESX hosts","# of VM" |  Export-Xls -Path C:\report.xls -WorksheetName $_.Name  Disconnect-VIServer -Server $currentvc -Confirm:$false}

You will have to render the Xls export function.

Simplest is to include in the script with the code above.

The name of the group is reflected in the name of the worksheet, having a separate line would be a little more difficult.

Tags: VMware

Similar Questions

  • Find records VM size and export to csv format

    Hello

    I need this script to export to csv format, but I have problems to make it work.

    Notice-EEG - ViewType VirtualMachine-property name, Config.Hardware.Device, LayoutEx | %{

    $viewVM = $_; $viewVM.Config.Hardware.Device |? {$_-is [VMware.Vim.VirtualDisk]} | %{

    # for each device VirtualDisk, get some info

    $oThisVirtualDisk = $_

    # get the disk element LayoutEx, which corresponds to the VirtualDisk

    $oLayoutExDisk = $viewVM.LayoutEx.Disk |? {$_. {Key - eq $oThisVirtualDisk.Key}

    # get the FileKeys that correspond to the LayoutEx-> sort items of this VirtualDisk

    $arrLayoutExDiskFileKeys = $oLayoutExDisk.Chain |? {$_-is [VMware.Vim.VirtualMachineFileLayoutExDiskUnit]}

    New-Object PSObject-property @ {} TypeName

    # Add the VM name

    VMName = $viewVM.Name

    # disc label, such as "disk 1".

    DiskLabel = $_. DeviceInfo.Label

    # the path to the data store for the file VirtualDisk

    DatastorePath = $_. Backing.FileName

    # the size provisioned to the VirtualDisk

    ProvisionedSizeGB = [Math]: tour ($_.) CapacityInKB / 1 MB, 1).

    # Get the file LayoutEx elements that correspond to the FileKeys for this LayoutEx disk and the size for items that are "diskExtents" (retrieved in the form of bytes, so convert to GB)

    SizeOnDatastoreGB = [Math]: round (($arrLayoutExDiskFileKeys | % {$_.)) FileKey} | % {$intFileKey = $_; $viewVM.LayoutEx.File |?} {($_. Eq - $intFileKey - button) and ($_.) Type - eq "diskExtent")}} | Measure - Object - size of the sum). Summary / 1 GB, 1).

    } # end new object

    } # end foreach-object

    } # end external foreach-object

    Capture all the output in a variable and send this variable in a CSV file.

    Something like that

    $result = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device, LayoutEx | %{
        $viewVM = $_; $viewVM.Config.Hardware.Device | ?{$_ -is [VMware.Vim.VirtualDisk]} | %{
            ## for each VirtualDisk device, get some info         $oThisVirtualDisk = $_        ## get the LayoutEx Disk item that corresponds to this VirtualDisk         $oLayoutExDisk = $viewVM.LayoutEx.Disk | ?{$_.Key -eq $oThisVirtualDisk.Key}
            ## get the FileKeys that correspond to the LayoutEx -> File items for this VirtualDisk         $arrLayoutExDiskFileKeys = $oLayoutExDisk.Chain | ?{$_ -is [VMware.Vim.VirtualMachineFileLayoutExDiskUnit]}
            New-Object -TypeName PSObject -Property @{
                ## add the VM name            VMName = $viewVM.Name
                ## the disk label, like "Hard disk 1"            DiskLabel = $_.DeviceInfo.Label
                ## the datastore path for the VirtualDisk file            DatastorePath = $_.Backing.FileName
                ## the provisioned size of the VirtualDisk            ProvisionedSizeGB = [Math]::Round($_.CapacityInKB / 1MB, 1)
                ## get the LayoutEx File items that correspond to the FileKeys for this LayoutEx Disk, and get the size for the items that are "diskExtents" (retrieved as bytes, so converting to GB)            SizeOnDatastoreGB = [Math]::Round(($arrLayoutExDiskFileKeys | %{$_.FileKey} | %{$intFileKey = $_; $viewVM.LayoutEx.File | ?{($_.Key -eq $intFileKey) -and ($_.Type -eq "diskExtent")}} | Measure-Object -Sum Size).Sum / 1GB, 1)
            } ## end new-object    } ## end foreach-object } ## end outer foreach-object
    
    $result | Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture
    
  • script to get the csv vm disk usage and export to csv format

    Hi all

    I am trying to create a script to get the use of disk for vm - space - free space and total disk space.

    I used this script that allows me to get the required result.

    but I need to edit the script for each cluster, VM he should get computers virtual cluster and check the vm disuage. and export of csv file

    $vms = import-CSV "C:\Cluster.csv".

    $outputfile = "c:\Diskusage.csv".

    SE connect-viserver VC-vcadmin username-password

    {foreach ($vm to $vms)

    Get - VM $vm.name | Where {$_.} PowerState - eq "Receptor"} | Get-VMGuest | Select the ExpandProperty - VMName disks | Select VMName, path, @{Name = "DiskCapacityGB"; Expression = {[math]: Round ((($_.))} {{((Ability) / 1 GB), 2)}}, @{Name = "DiskUsedMB"; Expression = {[math]: Round ((($_.))} Capacity - $_. {{((FreeSpace) / 1 MB), 2)}}, @{Name = "DiskFreeMB"; Expression = {[math]: Round ((($_.))} {{((FreeSpace) / 1 MB), 2)}} | Export-Csv - NoTypeInformation $outputfile}

    Viserver disconnect

    Joint the output file

    Veuileez help me in creating the script

    You can try like this?

    Connect-viserver VC -user vcadmin -password
    foreach($cluster in Get-CLuster){
        $outputfile = "c:\" + $cluster.Name + "-Diskusage.csv"    Get-VM -Location $cluster |
        Where { $_.PowerState -eq "PoweredOn" } |
        Get-VMGuest |
        Select VMName -ExpandProperty Disks |
        Select VMName, Path,
            @{Name="DiskCapacityGB";Expression={[math]::Round((($_.Capacity)/1GB),2)}},
            @{Name="DiskUsedMB";Expression={[math]::Round((($_.Capacity - $_.FreeSpace)/1MB),2)}},
            @{Name="DiskFreeMB";Expression={[math]::Round((($_.FreeSpace)/1MB),2)}} |
        Export-Csv -NoTypeInformation $outputfile}
    
    Disconnect-viserver
    

    The script creates a CSV file for each cluster.

  • I have created a multi-page document in inDesign and exported in PDF format.  The original file size is 13.27 mb.  I used the command size reduced to 2.86 to the file to download on the internet.  However, one of the images in the original pdf file does n

    I have created a multi-page document in inDesign and exported in PDF format.  The original file size is 13.27 mb.  I used the command size reduced to 2.86 to the file to download on the internet.  However, one of the images in the original pdf file does not appear in the smaller file.  Can someone help me?

    Try the PDF tool optimize.

  • Remove "< div" Excel file when exporting to CSV format

    Hello
    I have a report has the following properties:
    Export of reports
    Activate the output CSV = > Yes
    Bind the Label = > export to CSV format

    but when I run the report and press the link, I get an excel sheet indicating the reeport data, but the problem is that the report began with
    < div id = "report_11749113153378136_catch" >, Iam if you're wondering how to solve the problem.
    Thank you
    Abdul Alkhateeb

    Published by: dtabed on March 18, 2009 07:58

    Hi Adam,.

    What version of APEX are you running? I think that this has been fixed in 3.1.2. If you disable partial-page refresh, that should get rid of your problem.

    Martin

    -----
    [http://apex-smb.blogspot.com/]

  • Problem report of multiple pages for ppt export

    Hi, I'm using version 11.1.2.1.0.83 workspace. When I export a report of multiple pages for powerpoint (from file/export/powerpoint) the ppt file created has just one page, which is the last page of the pdf report.

    Someone knows how to fix this bug, which is to export the powerpoint with the same numebr of pdf report pages?

    You can use Smart View of powerpoint and get the report here. You don't need external program.

    Concerning

    Celvin

    http://www.orahyplabs.com

  • Leading zeros and export to CSV


    Hello

    I run a sql query for retrieving telephone numbers and when exporting to CSV 0 are deleted. I understand that this is a problem of excel formatting, however does it perform a work around in the SQL that can preserve the leading zeros when exporting to CSV?

    sliderrules wrote:

    The format of data is of type char

    SELECT «=» | test ctelno

    When they are copied to surpass the value bed = 0999 6767 in excel (including =)

    You need double quotes

    '="'|| c.ctelno |' » "

  • Output on screen and EXPORT. CSV

    Hi all

    Were the creation of scripts for some general tasks and I got a little confused on what is happening.  I have two scripts that are output on the screen even with EXPORT. CSV commond to end.  I get the output sent to the CSV fine and there is no obvious errors.

    Any whay Idears, that this could happen?  I can post my script if that helps.

    Thank you

    Phil

    This is the line with only $objHba in it.

    It will display the content of this variable to the screen.

    # $vmlist = Get-VM
    $table = @()
    
    foreach ($vmhost in (Get-view -ViewType Hostsystem )) {
         foreach ($hba in ($vmhost.config.storagedevice.hostbusadapter | where {$_.PortWorldWideName})) {
              $objHba = "" | Select-Object Hostname,Device,Model,Driver,Pci,Wwpn
              $objHba.HostName = $vmhost.Name
              $objHba.Device = $hba.Device
              $objHba.Model = $hba.Model
              $objHba.Driver = $hba.Driver
              $objHba.Pci = $hba.Pci
              $objHba.Wwpn = "{0:x}" -f $hba.PortWorldWideName
    #           $objHba
              $table += $objHba
         }
    }
    
    $table | Export-Csv $outputDir\data\$date.$viserver.$filename.csv -NoTypeInformation
    

    BTW what is the first (of line) doing here? It has nothing to do with the rest of the script.

    Copy & paste mistake I guess?

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Inventory of record Export in CSV format

    Hello

    I'm looking for a way to export the folders from the virtual computer inventory to a CSV file. Ideally, the list would include the path to the folder, the total number of VMS, vCPUs and RAM provisioned put in service. I would like the script to vCenter instead of by the datacenter or cluster.

    a.PNG

    Path of the folder.          # VMs          |          # vCPUs |           RAM (GB)

    Cluster\Group1               1                              1                                   1

    Cluster\Group2               2                              1                                   2


    Any help is appreciated, thank you very much.

    Try something like this, it descends recursively the blue folder structure.

    Be sure to change the Datacentername!

    Function Get-FolderPath {}

    Param($FolderMoRef,$path='')

    $Folder = get-view-Id $FolderMoRef

    If ($Folder.Name - don't 'vm') {}

    If ($Path - eq '-') {}

    $currentPath = "$Path $($Folder.Name)".

    }

    else {}

    $currentPath = ' $Path\ $($Folder.Name).

    }

    }

    else {}

    $currentPath = "\"

    }

    $vmIds = $Folder.ChildEntity | where {$_.} Type - eq 'VirtualMachine'}

    {if ($vmIds)}

    $vms = get-view-Id $vmIds

    New-object PSObject-property @ {}

    FolderPath = $currentPath

    '#VM' = $vms. County

    '#vCPU' = $vms | %{$_. Config.Hardware.NumCPU} | Measure-object-sum | Select - ExpandProperty sum

    "GB vRAM" = [math]: Round (($vms | % {$_.)) Config.Hardware.MemoryMB} |

    Measure-object-sum | (Select sum - ExpandProperty) / 1 Ko, 1).

    }

    }

    else {}

    New-object PSObject-property @ {}

    FolderPath = $currentPath

    '#VM' = 0

    '#vCPU' = 0

    "GB vRAM" = 0

    }

    }

    $folderIds = $Folder.ChildEntity | where {$_.} Type - eq "File"}

    {if ($folderIds)}

    $folderIds | %{

    Get-FolderPath-record $_-path $currentPath

    }

    }

    #  }

    }

    $dcName = "DC".

    $root = get-data center-name $dcName | Get-file-name "vm".

    Get-FolderPath - FolderMoRef $root. ExtensionData.Moref |

    Select FolderPath, "#VM", "#vCPU", "GB vRAM |

    Export Csv c:\vm-folder-report.csv - NoTypeInformation - UseCulture

  • Why do I get System.String [] when I export to CSV format instead of the data that I'm looing?

    I HAV a real simple script that pulls information about DNS configuration & my ESXi hosts routing settings. version of ESXi 4.1 is

    Get-VMHost | Get-VMHostNetwork | Select VMHost, VMKernelGateway, DnsAddress, DnsFromDhcp, hostname, domain name SearchDomain

    When I use the above script I get the result on the screen I want to see:

    $vmhost: MyHostDisplayName1

    VMKernelGateway: 10.10.10.10

    DnsAddress: {10.10.10.11, 10.10.10.12}

    DnsFromDhcp: false

    HostName: MyHostName1

    Domain name: MyDomainName.local

    SearchDomain: {MyDomainName.local}

    When I try to channel this output in CSV format, I find myself with a problem:

    Get-VMHost | Get-VMHostNetwork | Select VMHost, VMKernelGateway, DnsAddress, DnsFromDhcp, hostname, domain name SearchDomain | Export-Csv C:\VMHostDNSinfo.csv

    My CSV does not show the SearchDomain or the DnsAddress. How to replace the [System.Stinr] with a correct output?

    VMHost

    VMKernelGateway

    DnsAddress

    DnsFromDhcp

    Host name

    Domain name

    SearchDomain

    MyHostDisplayName1

    10.10.10.10

    System.String]

    FAKE

    MyHostName1

    MyDomainName.local

    System.String]

    MyHostDisplayName2

    10.10.10.9

    System.String]

    FAKE

    MyHostName2

    MyDomainName.local

    System.String]

    MyHostDisplayName3

    10.10.10.8

    System.String]

    FAKE

    MyHostName3

    MyDomainName.local

    System.String]

    You must convert arrays to strings before exporting them one. CSV file. You can do this with the following script:

    Get-VMHost | Get-VMHostNetwork | `
    Select-Object VMHost, VMKernelGateway,
      @{N="DnsAddress";E={[string]::Join(",",$_.DnsAddress)}},
      DnsFromDhcp, HostName, DomainName,
      @{N="SearchDomain";E={[string]::Join(",",$_.SearchDomain)}} | `
    Export-Csv -Path VMHostDNSinfo.csv -NoTypeInformation -UseCulture
    

    Best regards, Robert

  • Export to CSV format without quotes

    When I export to CSV, I want to do without surrounding quotes data...

    I found other posts that confirmed this was not possible in SQL Developer 1.x, but I use the version 2.1.0.63 - anyone know if it is possible in this version?

    Thank you
    Emily

    Currently, there is no way to do this. However there was a feature presented in March 2008 request, asking this (among others); It is marked as "Accepted", but has only 3 votes. I suggest you add your vote to increase the chances it can get implemented at some point. The URL is http://htmldb.oracle.com/pls/otn/f?p=42626:39:1619641722802622:NO:P39_ID:10481.

    HTH.

    Hrsg.:.

  • report for multiple virtual machines created

    I have a virtual machine creation script that I modified in order to be able to run in a loop using a CSV file to create more than one virtual machine at once. My original script send me an e-mail message for example:

    VM

    IPaddress

    CENTRAL PROCESSING UNIT

    Memory

    ToolsVer

    ToolStatus

    Data store

    Folder

    ESXiHost

    MyVM

    123.45.67.89

    3

    4096

    8384

    toolsOk

    myDS

    My-file

    myesxhost

    The problem that I want to try to figure out how can I get ALL the VM's on an e-mail report. Right now, because it's a loop, each VM I create will send a report. So if I put it up to build 4 vm, it will send 4 emails... I don't like it.

    How my script works pretty well...

    {foreach ($var in $vmlist)

    script here

    ...

    ...

    ...


    # Create and send emails report - Start #.
    #
    Function create HTMLTable {}
    Param([array]$array)
    $arrHTML = $Array | ConvertTo-Html
    $arrHTML [-1] is $arrHTML [-1]. ToString(). Replace ("< body / > < / html >", "")
    Return $arrHTML [5.2000]
    }

    $output = @)
    $output += ' < html > < head > < / head > < body table > < style > {border-style: solid; border-width: 1px; police-size: 8pt; background-color: #ccc; width: 100% ;}} Th {text-align: left ;}} TD {background-color: #fff; width: 20%; border-style: solid; border-width: 1px ;}} Body {do-family: verdana; do-size: 12pt ;}} H1 {make-size: 12pt ;}} H2 {make-size: 10pt ;} < / style > '}
    $output += ' < H2 > the virtual machines created < / H2 > '
    $output += ' < H2 > < / H2 > '
    #$Report = @)
    $Report = New-Object - TypeName system.collections.arraylist
    foreach ($vm in get-vm-name $var.myvms)
    {
    ...

    ...

    ...

    ...

    ...
    $report.add ($reportedvm) | out-null

    }


    If ($HTML - eq 'Yes') {}
    $output += '< p > '.
    $output += '< p > '.
    $output += create HTMLTable $report $output += '< /p >.
    $output += ' < body / > < / html > "
    $output | Add a content-$FileHTML
    }
    If ($SendEmail - eq 'Yes') {}
    $body = get-Content $FileHTML | Out-string
    Send-MailMessage - to $EmailFrom - to $EmailTo - subject $EmailSubject - SmtpServer $EmailSMTP - body $body - BodyAsHtml}
    #

    }

    OK, I have to spend it at the moment, I can't work.

    Thank you

  • Get-Annotation and export to CSV

    I am trying to export of Annotation custom fields in a CSV with foreach and difficulty to operate there where I want.

    1. is it possiible export with foreach or do I have to use foreach-object?

    $vms = get-vm pt*
    foreach ($vm in $vms){
        $vm = Get-View $vm.ID
        $nm = $vm.name
        $hn = $vm.guest.hostname
        $ip = $vm.guest.ipaddress
        $contact = get-vm $vms | Get-Annotation -CustomAttribute "System Contact"|select Value
        $vm | select `
        @{Name = "Name"; E={$nm}},`
        @{Name = "Contact"; E={$contact}},`
        @{Name = "Hostname"; E={$hn}},`
        @{Name = "IP"; E={$ip}}
    }format-table -AutoSize -Wrap

    2. How can I get rid of the "{@{value ="in the exit?}} "

    Name                          Contact                       Hostname                      IP
    ----                          -------                       --------                      --
    PT1                      {@{Value=abcd.Serverteam...     pt1.abcd.com              10.0.1.5
    PT2                      {@{Value=abcd.Serverteam...     pt2.abcd.com              10.0.1.33

    The better, more PowerShell, way to do this would be to use the pipeline.

    Something like that

    Get-VM tp* | Select Name,  @{N="Hostname";E={$_.Guest.Hostname}},  @{N="IP address";E={$_.Guest.IpAddress}},  @{N="Contact";E={
        Get-Annotation -Entity $_ -CustomAttribute "System Contact" |
        Select -ExpandProperty Value}} | Export-Csv c:\report.csv -NoTypeInformation -UseCulture
    
  • OE error export to CSV format

    Outlook Express 6.00.2900.5512 (with XP Pro SP3) will not export to a. CSV file. The error message "Error exporting the address book" shows every time. I tried to export a new file name and also to a. CSV file saved with Excel.

    Thanks for the suggestion, but it didn't work. Always to receive the same error message trying to export a new file or a .csv file that is saved on the desktop.

    I am logged on as administrator so I hope this isn't a permission problem.

    Just a thought and copied the file .wab Desktop on an old laptop. Ensuring that the export worked properly in the computer first, and he did. Then I renamed the files and tried to export the address book of office on the laptop, and it did not work. Which means there is probably something wrong with the office .wab.

    Is that what you heard before?

  • export to csv format

    Import-Csv c:\temp\esx.csv | {foreach}

    SE connect-VIServer-Server $_. HV-user $user-Password $password

    $rootFolder = get-file-name root-folder-ha

    Get-VIPermission-Server $esx | where {$_.} Role - eq "Admin"} | Export-Csv - NoTypeInformation - UseCulture c:\xxx.csv > > > > >?

    Disconnect-VIServer-confirm: $false

    }

    above is not... How to do things in exported xls?

    Thank you

    Something like that

    $report = @)

    Import-Csv c:\temp\esx.csv | {foreach}

    SE connect-VIServer-Server $_. HV-user $user-Password $password

    $rootFolder = get-file-name root-folder-ha

    $report += get-VIPermission-Server $esx | where {$_.} Role - eq "Admin"} |

    Select the entity, Principal, propagate, IsGroup

    Disconnect-VIServer-confirm: $false

    }

    $report | Export-Csv - NoTypeInformation - UseCulture c:\xxx.csv

Maybe you are looking for