Script to export specific elements of the VM inventory, by folder

Hi all

I was trawl through the discussions here... and I think this has already been done before, but maybe not in the same script... and I'm not much more than a writer.

I'm looking to export to CSV, the following information for each virtual computer, but sorted by folder:

Folder name, VM name, no. vCPUs, memory, HDD (GB) SCSI ID/Virtual Device Node, the size of the disk in GB (size provisioned)

that is something that would be output similar to (assuming that 'Customer ABC' is the name of the folder):

ABC's of customer, Server1, 4, 16, SCSI (0,0) 1, 60GB, a SCSI hard drive hard drive (0.1) 2, 20GB

Customer ABC, Server2, 2, 8, SCSI (0,0) 1, 60GB, a SCSI hard drive hard drive (0.1) 2, a SCSI hard drive, 20GB (0.2) 3 250 GB

Who is?  I don't know that lucd has something up his sleeve for this. Not too worried if the description of the hard drive is not exactly the above (to be honest, just the SCSI ID or "Hard disk 1' etc, it would be perfect). As each VM is likely to have a different number of hard drives, and I want that all information for each VM on the same line... It is probably best to put the info hard drive at the end.

We have about 200 VMS, and it will grow - so I wonder if something with 'Get-View "?  I read everywhere and it seems that this method is fast enough.  Furthermore, a script where we set the variable of the specific file we want to question rather than in the object of data centre?

Any help on this is much appreciated - let me know if the above makes no sense.

Cheers, James

All credit goes to Lucd and Alan Renouf.

$Information = @()
$Vminfo = Get-VM | Select-Object *, @{N="HDDs"; E={$_ | Get-HardDisk}}, @{N="HDDcount"; E={($_ | Get-HardDisk).length}}
$vmlist = $Vminfo | Sort-Object -Descending HDDcount
foreach ($vm in $vmlist) {
    #$Harddiskinfo = $vm | get-harddisk
    $props = New-Object PSObject
    $props | Add-member -name "Folder" -Membertype NoteProperty -Value $vm.folder
    $props | Add-member -name "VMName" -Membertype NoteProperty -Value $vm.Name
    $props | Add-member -name "vCPUs" -Membertype NoteProperty -Value $vm.NumCpu
    $props | Add-member -name "Memory(GB)" -Membertype NoteProperty -Value $vm.MemoryGB
    $DiskNum = 0
    foreach ($hdd in $vm.HDDs) {
        $controllerinfo = $hdd.ExtensionData
        $controllerkey = $controllerinfo.controllerkey.tostring()
        $keycount = ($controllerkey |  measure-object -Character | Select-Object -expandproperty Characters).tostring()
        $virtualID = "{0}:{1}:{2}" -f $controllerkey.substring(0,1), $controllerkey.substring($keycount - 1), $hdd.ExtensionData.Unitnumber
        $props | Add-member -name "Disk$($DiskNum)scsiID" -Membertype NoteProperty -Value $virtualID
        $props | Add-member -name "Disk$($DiskNum)Harddisk" -Membertype NoteProperty -Value $hdd.Name
        $props | Add-member -name "Disk$($DiskNum)Size(GB)" -Membertype NoteProperty -Value $hdd.CapacityGB
        $DiskNum++
    }
     $Information += $props
}
$Information | Out-GridView

Reference URL

http://www.virtu-al.NET/2009/11/17/PowerShell-gotcha-Export-CSV-out-GridView-and-others/

Tags: VMware

Similar Questions

  • How to change a specific element in the table

    Hello

    I have a chart intialized 1 d

    I want to take the table exist and for example to add + 1 to the 5th element

    How can it be done?

    Thank you

    If you have a newer version of LV, the Structure of elements in Place can simplify this.

    Lynn

  • conditional script by a specific part in the docname

    I did something to have that kind of stenosis on photo I'm working:

    0000000000001_v1_fg1208015_det.jpg

    I would like to know if I can do a part of the name, for example one secured a part named script v1 is (view 1).

    but I had also, at the same place in the structure v2 or v3, etc...

    My idea is to make a script of what a State part of the name of the document.

    Thx for help

    If you want to make this one document at a time (or automate > batch on an entire folder later) use this:

    var workingName = app.activeDocument.name;
    if(workingName.match(/(v1)/ig)){
        //do something
        } else if (workingName.match(/(v2)/ig)){
        //do something
        } else if (workingName.match(/(v3)/ig)){
        //do something
    }
    

    If you want to loop through all open documents, use this:

    for (i = 0; i < documents.length; i++){
        var curDoc = app.activeDocument = app.documents[i];
        var workingName = curDoc.name;
        if(workingName.match(/(v1)/ig)){
            //do something
            } else if (workingName.match(/(v2)/ig)){
            //do something
            } else if (workingName.match(/(v3)/ig)){
            //do something
            }
        }
    

    NOTE: the 'i' at the end of each pattern of regex converts this case... If you want it to be case sensitive to get rid of the 'i '. In addition, in the second option if the part 'do something' includes the closure of the document, that rise out of the loop. In this case change the iteration backwards like this:

    for (i = app.documents.length - 1; i >= 0; i--)
    
  • Unable to export specific tables in the schema.

    I created a schema duser, the data is imported and now I want to take some pictures from this scheme.
    the tables are (partyhdr, partyaddressdtl, partycontactdtl, partydsdtl, partytdsexcludedtl, partycurrencydtl)


    D:\ > EXP FILE DUSER/LOG@ORCL = 20121221PARTY0228PM. DMP TABLES = PARTYHDR, PARTYADDRESS
    DTL, PARTYCONTACTDTL, PARTYTDSDTL, PARTYTDSEXCLUDEDTL, PARTYCURRENCYDTL;

    Export: Release 10.1.0.2.0 - Production on Fri dec 21 14:30:21 2012
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Release 10.1.0.2.0 - Production
    Export performed WE8MSWIN1252 and AL16UTF16 NCHAR character set
    About to export specified tables by conventional means...
    . . export of table PARTYHDR 19387 rows exported
    . . export of table PARTYADDRESSDTL 20747 rows exported
    . . export the PARTYCONTACTDTL 226 exported table rows
    . . export the PARTYTDSDTL 53 exported table rows
    . . export the PARTYTDSEXCLUDEDTL 2 exported table rows
    EXP-00011: DUSER. PARTYCURRENCYDTL; There is no
    Export completed successfully with warnings.

    as I check table in schema partycurrencydtl is their AND MONTRANT RECORDS.

    SELECT OBJECT_TYPE OBJECT WHERE OWNER = 'DUSER' AND OBJECT_NAME = "PARTYCURRENCYDTL";

    OBJECT_TYPE
    -------------------
    TABLE

    I can understand why this particular table does not export.

    Kindly help.

    Please use the below command without semicolon

    EXP FILE = 20121221PARTY0228PM DUSER/LOG@ORCL. DMP TABLES = PARTYHDR, PARTYADDRESS
    DTL, PARTYCONTACTDTL, PARTYTDSDTL, PARTYTDSEXCLUDEDTL, PARTYCURRENCYDTL

  • remove the specific element of the array

    Hello

    I would like to delete all the values '0' of the table.

    In the following table:

    -60

    -50

    0

    -60

    0

    0

    -55

    the leading array to return must be

    -60

    -50

    -60

    -55

    Any help will be greatly appreciated.

    Thank you

    hiNi.

    Have you tried a search? This issue has developed dozens of times.

    If the table is small table build in a loop as described is very good. However, for large networks, it's a BAD way to do it. Instead, you need an alternative

  • mathematical calculation in script on each element of the array.

    Hi all

    I am trying to write the VB script in which I want to do different mathematical operation on each element of channel-specific data. For example, for each element I want to find the next two index given way and both before and after publication of the results on the basis, then it is more calculating.

    It will be very useful if someone can guide me in the execution of operation on the elements in the array inside the script of tiara, that we can do in labview using indexes in the table. There are built-in math and statistics in tiara tab analysis tool. But I want to design for my custom mathematical operation.

    Thnks

    HS

    Hi HS,

    Here is a version 10.2 tiara from what I understand ask you:

    Window = 2

    Denom = 2 * window + 1

    Threshold = 10

    Chnum = CNo("[1]/Speed")

    FOR i = 1 + ChnLength (Chnum) window - window

    Sum = 0

    FOR j = i - window to i + window

    Sum = sum + ChDX (j, Chnum)

    NEXT ' j

    Ave = sum/Denom

    IF Ave > threshold CAN

    ' do action of contingent

    END IF

    NEXT ' I

    Brad Turpin
    Tiara Product Support Engineer
    National Instruments

  • Masking of XML elements in the structure view - influence the view of the structure of script?

    Hello

    Is there a way to hide items specific XML (really the elements and attributes) in the display of the structure?


    I ask this question: is it possible to influence the structure seen by the script.

    A lot of elements is used as some kind of help for constructions that have nothing to do with the actual content, especially in the case of tables.

    You inflate the structure discovered unnecessarily and the author will lose track of the real content. It would be nice if there was a possibility to hide construction of help items.

    Thanks for the tips.

    Concerning

    Apollo102

    Apollo,

    The answer to this question is a simple "Yes." Each element object has an ElementIsCollapsed property that is set to true or false. When set to true, it is developed in view of the Structure. Otherwise, she is devastated. It works very well.

    Russ

  • How to change the value of the specific element of a cluster

    Hi all

    I have a cluster that contains the string for the most part, I want to change a specific value of an element of the latter. How can I do that.

    joined my vi

    Thank you

    Bundle name

  • How to insert table 1 d elements in specific place in the 2D array

    Hello

    I have a 2D color boxes [10 x 10] table, and I would replace elements with the elements of the array 1 d [4 items] at the precise place.

    When I try to use, subset table replace "I can only specify the INDEX ROW or COLUMN INDEX where to start to put new items. But I need to select the two column/row index.

    Any ideas?

    Hi kamill,.

    When replacing a 1 d table in a table 2D LabVIEW can only replace line - or columnwise.

    When you want to replace specific, but independent, elements that you must use an autoindexing FOR loop to iterate through items of your1D or the berries!

  • Need a little help. Script to export the single document for different types of files.

    Hey guys, I'm new to scripting. have looked everywhere but cannot find an answer to this, I'm sure it's pretty simple


    At work we export logos all the time in a few different formats for the clients.
    I looked in the script as a way to automate the process.

    So far, I thought a little script to export my Illustrator formats document... now I need to be able to export this document even outside as a res low and high PNG, low and high res JPEG, EPS, PDF and TIFF etc.
    I have scripts to do all these separately but just need to know how to put it all in a single script I can do all at once

    Here is an example of my two different scripts to export PNG. I just need to know how string together so I can add all of the formats without breaking it.

    function savePNG() {}
    var destFolder = Folder.selectDialog ("select the folder to export the PNG files to :');")
    If {(destFolder)
    If (app.documents.length > 0) {}
    var Nomdoc = app.activeDocument.name.match(/^.*[^.ai]/i);
    var destFile = new file (destFolder + ' /' + Nomdoc + "-HR.png");
    if(destFile == null) {return ;}
    var doc = app.activeDocument;
    var artRect = doc.artboards [0] .artboardRect;
    var exportOptions = new ImageCaptureOptions;
    exportOptions.resolution = 300;
    exportOptions.antiAliasing = true;
    exportOptions.transparency = true;
    doc.imageCapture (destFile, artRect, exportOptions);
    }
    }
    }
    savePNG();

    and here is the version low resolution

    function savePNG() {}
    var destFolder = Folder.selectDialog ("select the folder to export the PNG files to :');")
    If {(destFolder)
    If (app.documents.length > 0) {}
    var Nomdoc = app.activeDocument.name.match(/^.*[^.ai]/i);
    var destFile = new file (destFolder + ' /' + Nomdoc + "-LR.png");
    if(destFile == null) {return ;}
    var doc = app.activeDocument;
    var artRect = doc.artboards [0] .artboardRect;
    var exportOptions = new ImageCaptureOptions;
    exportOptions.resolution = 72;
    exportOptions.antiAliasing = true;
    exportOptions.transparency = true;
    doc.imageCapture (destFile, artRect, exportOptions);
    }
    }
    }
    savePNG();

    Thanks for any advice you can give!
    Eli

    Oh, you want to perform two functions, one after another at the same time? then just name with different names and perform one function after another, if all files will be saved in the same folder, the argument selectDialog move method on each of your functions to don't do only once.

    function savePNG_HR(){
        var destFolder = Folder.selectDialog('Select the folder to export the PNG files to:');
        if (destFolder) {
            if(app.documents.length > 0){
                var docName = app.activeDocument.name.match(/^.*[^.ai]/i);
                var destFile = new File(destFolder + '/' + docName + " - HR.png");
                if(destFile == null){return;}
                var doc = app.activeDocument;
                var artRect = doc.artboards[0].artboardRect;
                var exportOptions = new ImageCaptureOptions;
                exportOptions.resolution = 300;
                exportOptions.antiAliasing = true;
                exportOptions.transparency = true;
                doc.imageCapture(destFile, artRect, exportOptions);
            }
        }
    }
    
    function savePNG_LR(){
        var destFolder = Folder.selectDialog('Select the folder to export the PNG files to:');
        if (destFolder) {
            if(app.documents.length > 0){
                var docName = app.activeDocument.name.match(/^.*[^.ai]/i);
                var destFile = new File(destFolder + '/' + docName + " - LR.png");
                if(destFile == null){return;}
                var doc = app.activeDocument;
                var artRect = doc.artboards[0].artboardRect;
                var exportOptions = new ImageCaptureOptions;
                exportOptions.resolution = 72;
                exportOptions.antiAliasing = true;
                exportOptions.transparency = true;
                doc.imageCapture(destFile, artRect, exportOptions);
            }
        }
    }
    savePNG_HR();
    savePNG_LR();
    
  • Some hyperslinks in the exported PDF file takes the Viewer to the pages "broken/missing. For example, the hyperlinks to specific of Youtube videos does not work, they brought to a youtube page is missing.

    Some hyperslinks in the exported PDF file takes the Viewer to the pages "broken/missing. For example, the hyperlinks to specific of Youtube videos does not work, they brought to a youtube page is missing.

    Hi Sarah!

    I solved it! I had to use the original URL shorter links to create

    functional hyperlinks or try to short the links using Google URL Shortener.

    I don't know why it worked by doing this, but he did!

    With the friendly and happy greetings!

    Sonny. A

    2015-11-24 9:32 GMT + 01:00 aadeshs76610910 [email protected]>:

    You talked

    by aadeshs76610910

    https://forums.Adobe.com/people/aadeshs76610910?et=notification.mention> * in

    Re: A few hyperslinks in the exported PDF file takes the Viewer to

    pages "broken/missing. For example specific Hypertext to Youtube videos links

    does not work, they will bring to a youtube page is missing. in Adobe

    Community *-view aadeshs76610910 you reference

    https://forums.Adobe.com/message/8209923?et=notification.mention#8209923>

  • How to pass the content of an xml element in the text frame in inDesign Script

    var XMLFile = File.openDialog ("select XML Files... ») ;

    var doc = app.activeDocument;

    If (!) App.Documents.Length)

    {alert ("ERROR: Document not opened");}

    return;

    }

    doc.importXML (XMLFile);

    var firstFigureNode = doc.xmlElements [0] .xmlElements [1] .xmlElements [0];

    var lableNode = firstFigureNode.xmlElements [0];

    var lableNodeText = lableNode.contents;

    myFrame var = doc.textFrames.add ({geometricBounds: [-13, 13, 3, -3]});

    lableNodeText.move (LocationOptions.AFTER, myFrame.texts [0]);

    ========================================================

    My requirement is: == > > move the content of an xml element in the text by inDesign Script block, but XML InDesign file Structure should not be change & data in the XML Structure should remain as it was before...

    I tried to code above, but it does not work...

    Please can someone help me in solving this problem...

    It does not work correctly...

    It moves firstFigureNode in myFrame...

    firstFigureNode.placeXML (myFrame);

    ===>> For Apple Script try below Code ===>>

    myFrame markup using firstFigureNode

  • Using CS4 Flach and action script 2.0 how to move a specific frame in the main timeline when a movie clip instance come at the end of his chronology?

    Using CS4 Flach and action script 2.0 how to move a specific frame in the main timeline when a movie clip instance come at the end of his chronology?

    code on the last frame of your movieclip instance:

    _root.gotoAndStop ('whatever_frame');  will work unless this swf is loaded into another swf.  in this case, you must use a relative path to the main timeline (for example, _parent or _parent._parent etc.).

  • Is it is possible to add script in Adobe Muse? I have added the functionality to export file .csv to the contact form

    Is it is possible to add script in Adobe Muse? I have added the functionality to export file .csv to the contact form

    Hi Vicky,

    Yes, you can add scripts customized to a page of muse. To do this, you must go to 'properties-> metadata-> html to head page' or ' object-> insert html.

    - Abhishek Maurya

  • Script to export information about LUNS - try to iron out the kinks

    I have a script which aims to export the details on the LUN information for the ESX hosts in a particular place. Here's the syntax:

    Report_LUN_Details_Location.ps1 where is introduced in the - position inside the script parameter. The script returns the content in c:\temp in the CSV format. Most of it works, but I have a problem with the path information access which to correctly report. Also, there are errors during execution of the script, but that does not affect the result. There also a few custom fields to communicate their data from EMC Symmetrix devices. Advice on how to improve/correct the script would be more appreciated.

    Thank you

    Ed

    The string error you see is the UUID to local disks is shorter than that of the SAN disks.

    Most of the time these local disks have the word "local" in the displayname property.

    If you can filter them by replacing it

         foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware"})
    

    by

         foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware" -and $_.DisplayName -notmatch "local"})
    

    The empty DevicePath property is due to disk devices.

    If I replaced this line

         foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware"})
    

    by this line

         foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware" -and $_.LunType -eq "disk"})
    

    This problem has disappeared.

    BTW, why do you test for vendor VMware?

    Is your set up running on a VMware Workstation perhaps?

    The complete script is attached.

    ____________

    Blog: LucD notes

    Twitter: lucd22

Maybe you are looking for