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

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
    
  • 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/]

  • 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

  • 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.

  • 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.:.

  • 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.

  • 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

  • Restrict the records in the CSV, based on condition

    Greetings. I searched the forum for my problem and have not found an answer or the right search terms. I'm under APEX 4.1.1

    I have a report on a page. I show all the records to a SQL query given in my table, but in the 'export to CSV' I need limit the output based on one of the fields. Thus, for example, if I had a report such as:

    SELECT x, y, Z
    FROM Table1

    I would like to export to CSV format for this table to limit the output such as:

    SELECT x, y, Z
    FROM Table1
    WHERE Z = 1

    Is this possible?

    Thank you!
    John

    Hi John,.

    I tested the connection now and works above for interactive report only and for the classic report, you need to do something like that because the demand is set to a different value

    SELECT x, y, Z
    FROM Table1
    WHERE ((Z = 1 and nvl(:REQUEST,'X') like 'FLOW_EXCEL_OUTPUT%') OR nvl(:REQUEST,'X') not like 'FLOW_EXCEL_OUTPUT%')
    

    See this example of work http://apex.oracle.com/pls/apex/f?p=46417:25

    When you export to CSV you'll get 10 dept records

  • don't DIAdem no value in csv format

    Hi all! / Hola a todos

    I have a question regardin the TDM export process to csv... some of my channels have no values and in the moment to export without values I get an empty 'cell' is possible that instead of vacuum, I can add the NaN or no. values in the moment of the export? I use the command DataFileSave--> Call DataFileSave (FileNamePath, "CSV")

    Tengo una pregunta relacionada con el proceso exportar a TDM a CSV... Aalgunos MIS canales 'NO VALUES' tienen el momento exportar estas posiciones y me generan 'cells' vacias. Are alguna manera put Nan o No al momento exportar el fichero value? Estoy utilizando el comando DataFileSave--> Call DataFileSave(FileNamePath, "CSV")

    Thank you for all your help

    Gracias a todos por su ayuda

    There is no way to influence the epresentation of a NOVALUE, while exporting to CSV format, it will always be the cell empty.

    The only way around this is to use the Excel add-in to load the tdm/PDM file directly.

    This will create a "#NV" in Excel.

    Sorry

    Andreas

  • I would like to export my contacts in .csv format. All the instructions say to click on the export button in my toolbar, but...

    I don't have the option to export anywhere.  I do not use Windows mail... I mainly use Contacts to my iPhone sync.  I am running Vista Home Premium 64-bit.  I need to get my contacts in .csv format into an excel spreadsheet.  Can someone help me with this please?

    You can watch the Contacts folder / View / "Customize this folder" (it's in the queue, Edit, 'View', tools and help Menu bar).

    In contact properties page, verify that the folder uses the model of Contacts and not any other model such as "All items" etc.  With a bit of luck you should now see the options to import and export on the toolbar.

  • How to export my Contacts in Windows Mail (CSV format, for example)?

    How to export my Contacts in Windows Mail (CSV format, for example)?

    Thank you!

    Hello

    See if that helps you.

    http://www.howtogeek.com/HOWTO/4905/backup-Windows-mail-messages-and-contacts-in-Vista/

    See you soon.

  • APEX 5.0 Export to CSV produces duplicate records

    Good day to you all:

    I use APEX 5.0, and I have a classic report that has a total number of lines of 274.  (274 documents also in SQL Developer).  However, when I export the report to CSV, duplicate records are produced and the total number of lines increases to 365.  Has anyone already known this before bug in APEX 5.0?  I tried to reproduce the report to a type of interactive, but I get the same results when you export to CSV.  Advice or guidance would be appreciated.  Thank you.

    Aqua

    Hey Aqua,

    If you are APEX 5.0.0 or 5.0.1? And which version of the database, you are on?

    There was a problem with CLOB (which are used for the download) in 5.0.0 running on specific versions of 11 GR 2. A fix is included in the 5.0.1 patch set.

    Concerning

    Patrick

  • Export of string in csv format, keeping the commas and new lines

    Hello

    I export the string to the csv format and have been removeing of new lines with commas as so

    thing.toString ().replace(/\n/g,_'').replace (',', ");

    How can I make this iwthout lose line breaks and commas? I can't have in atm as mess up the csv file.

    JSON is more 'transfer' information that can be gathered in number, string, array, object, etc format later.

    Excel can import CSV, but it cannot interpret the complexity of the information. Typically what you would do is serialize complex information with JSON, receive on the other side (where it is perhaps) and then to deserialize. After you are deserializing it using the capabilities of JSONs to put your information into what is was (numbers, strings, arrays, and object) it is up to you how you restructure the data to the format of your choice.

    Your original intent of preserving CSV is the best for Excel or OpenOffice Calc. You don't mention your intention. JSON would package these \n's (CRLF) for you.

Maybe you are looking for