Properties of the output array object

I worked on a simple script to pull machine virtual hard disk and the number of unique a VM vm/mutiple SCSI

But the output returned as an object + properties for EACH disc, what I want is a table without titles, or each vm as the object and HardDiskName, ScsiId, SizeGB, RawDeviceId, path as properties.

Any ideas?

for example

>.\Get-VmHdScsi.ps1 - VM vm1

Path of the RawDeviceId SizeGB HardDiskName ScsiId VMName

------     ------------ ------ ------ ----------- ----

VM1 disc 1 0: vm1/vm1.vmdk 0 36 [datastore]

Path of the RawDeviceId SizeGB HardDiskName ScsiId VMName

------     ------------ ------ ------ ----------- ----

VM1 disc 2 0:1 8 [datastore] vm1/vm1._1.vmdk

Path of the RawDeviceId SizeGB HardDiskName ScsiId VMName

------     ------------ ------ ------ ----------- ----

VM1 Disc 3 0: vm1/vm1._2.vmdk 2 26 [datastore]

<#
.Acknowledgment
    vNugglets http://www.vnugglets.com/2013/12/get-vm-disks-and-rdms-via-powercli.html
      
    .Example
    Get-VmHardDiskScsiId -vmName <vm>
  
    . Notes
    I have removed code that collects multiple vms
#>

# Set variables
[CmdletBinding()]
param (
[string]$vm = " "
)

## Use get-view to collect the VM object(s)
$VmView = Get-View -Viewtype VirtualMachine -Property Name, Config.Hardware.Device, Runtime.Host -Filter @{"Name" = "$vm"}
if (($VmView | Measure-Object).Count -eq 0) {Write-Warning "No VirtualMachine objects found matching name pattern '$vm'"; exit}

    $VmView | %{
        $viewVmDisk = $_
        ## get the view of the host on which the VM currently resides
        $VmView = Get-View -Id  $viewVmDisk.Runtime.Host -Property Config.StorageDevice.ScsiLun

        $viewVmDisk.Config.Hardware.Device | ?{$_ -is [VMware.Vim.VirtualDisk]} | %{
            $HardDisk = $_
            $ScsiLun = $VmView.Config.StorageDevice.ScsiLun | ?{$_.UUID -eq $HardDisk.Backing.LunUuid}
          
            ## the properties to return in new object
            $VmProperties = @{
                VMName = $viewVmDisk.Name
                HardDiskName = $HardDisk.DeviceInfo.Label
                ## get device's SCSI controller and Unit numbers (1:0, 1:3, etc)
                ScsiId = &{$strScsiDevice = $_.ControllerKey.ToString(); "{0}`:{1}" -f $strScsiDevice[$strScsiDevice.Length - 1], $_.Unitnumber}
                #DeviceDisplayName = $oScsiLun.DisplayName
                SizeGB = [Math]::Round($_.CapacityInKB / 1MB, 0)
                RawDeviceId = $ScsiLun.CanonicalName
                Path = $HardDisk.Backing.Filename
            }
          
            ## Select items for output
            $arrPropertiesToSelect = "VMName,HardDiskName,ScsiId,SizeGB,RawDeviceId,Path".Split(",")
            New-Object -Type PSObject -Property $VmProperties | Select $arrPropertiesToSelect | ft -a         
        }
}





This is because you do your Select-Object and Format-Table inside the ForEach loop.

Move those out of the loop.

Note that you must use the call operator (and), as the ForEach loop put anything in the pipeline.

$VmView = get-View - Viewtype VirtualMachine-property name, Config.Hardware.Device, Runtime.Host - filter @{"Name" = "$vm"}

If (($VmView |)) Measure - Object). Count - eq 0) {Write-Warning 'no found VirtualMachine object matching name model '$vm' '; exit}

$arrPropertiesToSelect = "VMName, ScsiId, HardDiskName, SizeGB, RawDeviceId, path. Split(",")

& {$VmView | %{}

$viewVmDisk = $_

# get the view of the host on which the virtual machine is currently

$VmView = get-view-Id $viewVmDisk.Runtime.Host - Config.StorageDevice.ScsiLun property

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

$HardDisk = $_

$ScsiLun = $VmView.Config.StorageDevice.ScsiLun |? {$_. {UUID eq - $HardDisk.Backing.LunUuid}

# to return to the new object properties

$VmProperties = @ {}

VMName = $viewVmDisk.Name

HardDiskName = $HardDisk.DeviceInfo.Label

# get the device SCSI controller and unit numbers (1:0, 1:3, etc.)

ScsiId = & {$strScsiDevice = $_.} ControllerKey.ToString (); "{0}" ': {1} "$strScsiDevice [$strScsiDevice.Length f - 1], $_." Unitnumber}

#DeviceDisplayName = $oScsiLun.DisplayName

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

RawDeviceId = $ScsiLun.CanonicalName

Path = $HardDisk.Backing.Filename

}

New-Object PSObject-property $VmProperties Type

}

}} | Select $arrPropertiesToSelect. FT - one

Tags: VMware

Similar Questions

  • Quiz of the properties "on the output.

    Can I have a slide of questionnaire use the action "Leaving" in the properties panel?  Why is it grayed on quiz slides?  What is a parameter or a preference, I need to change?

    Thanks in advnace.

    Hello

    Welcome to the Adobe Forums.

    Leaving the action has never been possible for question slides because when the user has accomplished in two steps in the process for asnwering a question (1. Submit, 2. Click the slide or press on Y) the actions defined on success/Last attempt so that the issue will be executed. It is integrated into the question slides.

    I don't think that we can change or alter this behavior.

    Kind regards

    Rajeev.

  • Changing the properties of the individual elements in the array

    In the attached VI, I have a table 1 d of the slider ('Phase Coefficients') controls where each element of the array represents the coefficient in a polynomial of arbitrary order. The problem I have is that the range of slider, I put to the coefficient of the lowest order (element 0 of the array) becomes quickly impossible for one more order coefficients (> 5 elements). Small changes in the highest order coefficients dramtically change the global polynomial.  I want each element/slider to have its own line, but I know that's not strictly possible that each element of a table shares the same properties. I've implemented a work around (use boolean to activate) in which the range of all cursors is set according to which the item is viewed, but my implementation prevents the modification of the range during execution of the VI. Is it possible to adapt my method (or use another method all together) in order to allow different, editable for each slider element ranges?

    Thank you!

    Each element of an array must have the same properties.  They can only differ in value.

    You can have an array of clusters, and each group can have the slider control.  Here, you will be able to regroup a slider with different properties in the cluster build clusters in a table.

  • account operators cannot read the properties of the user object

    Hello

    I have peripheral setup VPN to authenticate LDAP and have created an account (for example vpnuser) liaison for the device with the builtin account operators group membership.
    It's that it can not read the properties of the user as memberof.
    However if I explicitly read permissions to the account vpnuser then it works.
    Even when he added the account group always vpnuser Domain Admins cannot get the memberof property.
    I have already confirmed that account operators have full control over user objects and I did no setting on the default permissions except for the above to solve problems.
    All the tips, troubleshooting tips, please?
    Thank you so much everyone

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for Windows IT Pro Forums. Please post your question in the Technet Windows Forum.

    http://social.technet.Microsoft.com/forums/Windows/en-us/home?Forum=w7itpronetworking

     
     
     
  • How to change the properties of the management object EventManager

    Hi all

    I try to send the Message of the newspaper on the vMA Server vCenter installed on

    an ESXi 4.0 with the script attached

    I used the "LogUserEvent" method and it works, I can create user log in vCenter Server.

    And now I try to change the properties of the managed object 'Event manager' to change the categories (not only information, but beware,...) of the newspaper

    I turn... and I need help!

    I found nothing on the VMware documentation.

    Thank you very much

    So, it looks like you want to record the information of the application within your guest and somehow that will send to your vCenter or ESX (i) host? Why not just log on to the virtual machine?

    If you want to search for some of the VM events or events in general, take a look at this script that gives you an example on how: provisionedVMReport.pl

    If you really want browser real newspapers either vCenter or ESX (i) host, take a look at the DiagnosticManager and this method will be useful:

    BrowseDiagnosticLog

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

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    150 VMware developer

    If you find this information useful, please give points to "correct" or "useful".

  • Stop the audio of the Web object to the output of the screen - Cap 7

    I have a series of slides, each with a Web object. Each is a link to an HTML page with a player/MP4. If I want to go to the next slide when the movie is in play mode, the audio stops not at the output.  I can't make an action to the exit because audio is not a tip, but the Web object Action. Am I missing something obvious here?

    Thanks in advance...

    The Webpage.wdgt has been fixed by Adobe and will be available in their store by next month. In the meantime, if anyone needs the interaction between the Web object, contact Suresh Jayaraman by e-mail at [email protected].

  • How to see the output of an associative array in procedure

    Hello
    I tried the following code
    And confused about the research at the exit of the associative array.
    CREATE OR REPLACE PACKAGE test_pak1
    AS
       FUNCTION map_object (obj_typ_in VARCHAR2)
          RETURN VARCHAR2;
    
       CURSOR c_c1
       IS
          SELECT * FROM emp;
    
       TYPE test_ttyp IS TABLE OF c_c1%ROWTYPE
                            INDEX BY PLS_INTEGER;
    
       PROCEDURE search_obj (obj_type VARCHAR2);
    END;
    
    CREATE OR REPLACE PACKAGE BODY test_pak1
    AS
       FUNCTION map_object (obj_typ_in VARCHAR2)
          RETURN VARCHAR2
       IS
       BEGIN
          dopl ('Hello');
          RETURN abc;
       END;
    
       PROCEDURE search_obj (obj_type VARCHAR2)
       IS
          test_tab   test_ttyp;
       BEGIN
            DOPL  (test_tab);
          end;
       END;
    In the above code, I want to see the output of the test_tab located in the search_obj procedure.

    could you please help me in this

    Thank you

    Hi, smile,

    If you want to see records, you must put the lines in your table. Here's a solution: in this solution, I only edit the search_obj procedure of your package like this:

     PROCEDURE search_obj (obj_type VARCHAR2)
       IS
          test_tab   test_ttyp;
          test_tab_r   c_c1%ROWTYPE;
       BEGIN
            --test_tab;
            --Here we put something in test_tab
            OPEN c_c1;
    
            LOOP
                 Fetch c_c1 into test_tab_r;
                 exit when c_c1%NOTFOUND;
                 test_tab(test_tab.COUNT + 1) := test_tab_r;
             END LOOP;
            CLOSE c_c1;   
    
            FOR i IN 1 .. test_tab.COUNT LOOP
              dbms_output.put_line(test_tab(i).empno);
           END LOOP;
    
       END;
    

    Here is the result:

    SQL> exec test_pak1.search_obj('parameter_not_used_in_the_procedure');
    7369
    7499
    7521
    7566
    7654
    7698
    7782
    7788
    7839
    7844
    7876
    7900
    7902
    7934
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • question about document process plans and the properties of the form object

    The new version of the Workbench has a tool that allows us to print a report that displays the properties of the object used in a model or process shape card? For example... showing all properties such as size, models, fonts, by default, if a field is required or not, etc...? I also check to see if this feature has been added to the Workbench for Process Maps?

    No, it isn't, but there is a blog by John Briinkman entry that will analyze your form template give you some of this information. Here is a link to the blog entry:

    http://blogs.Adobe.com/formfeed/2011/05/updated-form-report-tool.html

    Paul

  • question about documenting the properties of the object

    The new version of the Designer has a tool that allows us to print a report that displays the properties of the object used in a form template? For example... showing all properties such as size, models, fonts, by default, if a field is required or not, etc...? I also check to see if this feature has been added to the Workbench for forms and for process cards too.

    Neal:

    This looks like a problem, you can solve with a designer macro.

    I have a sample macro that will summarize the properties for all objects in a form.

    You can customize the macro so that it reported on the selected objects

    The macro is described here:

    http://blogs.Adobe.com/formfeed/2011/05/updated-form-report-tool.html

    The latest version of the macro is here:

    http://blogs.Adobe.com/formfeed/2011/09/more-macro-goodies.html

    John

  • How can I spy on the properties of the object using oats 9.1

    Hi all

    How can I spy on the properties of the object in the oracle applications using oats9.1

    and also how to retrieve data from a database.

    Please help me on this point.

    Thank you
    Sudhir

    Hi sudhir,

    During recording, you can activate by clickign the icon 'Add Test object' object browser on the toolbar. You can highlight the object on the page and select by pressing F10. In the dialog box, and then choose the properties you want to test.

    See you soon,.
    Jamie

  • Adding objects to the stage &amp; amp; Properties of the acceessing Stadium - I'm a bit confused...

    Hello

    I'm a bit confused about the programming of the display's two-pronged:

    A. What are the best way to add objects to the stage?
    B. how to access the properties of the step.

    I can make these two when the project is a 'Action Script Project', but I have a problem when it is a "Flex project" (for example a MXML file). See the attached files two questions included in the commentary to see exactly what I mean.


    A. What are the best way to add objects to the stage?
    =====================================

    In a project of action script which extends Sprite I can call him addChild()

    In a project MXML I add objects to the scene first, adding them to a UIComponent, then adding that the step.

    1 - is the best way to do it?

    In this doc: http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html he says this quote from
    :
    Each SWF file has an ActionScript class associated with it, called the main class of the SWF file. When Flash Player opens a SWF file in an HTML page, Flash Player calls the constructor function for that class and the instance that is created (which is always a type of display object) is added as a child of the Stage object. The main class of a SWF file always extends the Sprite class
  • Setting the properties of the object in a class

    There is this contentItem class. The instance has been created well and all properties, with the exception of "maincopy", has been successfully. Now when I buckle my xml (the real path to the xml nodes have been removed for readability), the object in the class is not attributed correctly. In fact, it seems, that it is not given to all the...

    Why the undefined? It traces the "Accessories" "obj [Props]" correctly!
    Thanks for the help.

    Solution:

    var temp : ContentItem = new ContentItem(aNode.nodeName+"/"+R.link);
    and do all the public instead of private properties.

  • 2D Array element 1 duplicate an int and the other Date and time for the output to a file

    Try to change the example labview Agilent 34401 acquire and graph - SW Triggered.vi

    to display the data in a file with a date/time stamp, display things in a file delimited by commas, it's very simple in PHP, C, C++, and I heard this thing of labview was great fast tool but I work on this simple mod for 5 hours now and still cannot get this to work.

    I have attached my example updated, but I can't seem to get this thing to convert the date and time to something that can go in the same array as the data...


  • Properties of the objects in the original application reference

    I continue to ask this question, maybe it's the wrong question,

    but here again:

    Why can't change properties in the main application for a component of the original application?

    Thank you

    Doug

    change of the cn you... but the best way is to loosely couple both the parent and the child of the parent using the communication of custom events/event based.

    so, to use in this case custom events.

    http://cookbooks.Adobe.com/post_Very_simple_example_of_using_custom_events_to_pass-15466.h tml

    Oops... Looks like I already helped you on this...... Laughing out loud! still struggling?

    Post edited by: saisri2k2

  • Capture the output of a workflow in a different workflow

    I'm calling a WF1 workflow from another workflow WF2. I am able to do and WF1 is running perfectly in the background and the desired output via a return number. Newspapers of WF1 to verify that.

    But I want to capture the output (table/integer) to WF1 by WF2. I can't pass the exit (snapshots) WF2.

    I enclose the code and the journal of WF2. I enclose the code and WF1 journal as well.

    Well, well, you seem to met a strange problem... It was me frustrating because your code resembles a re-work of my code here:

    How to retrieve the details of Workflow

    ... If I run MY library workflow that checks the chips of workflow, the output, but all the variations, I tried to get out of the current token element has ended in the same result as what you had: null.

    So, as executions of audit workflow worked rather than the active token, wait until the workflow has completed, and then loop through the workflow runs until you find the one with the matching id of the token you just ran... once that you find, parse the output.

    Given two workflows you set in the last post, replace your task Scriptable text in the 'test' WF follows him with and run it (feel free to delete the code useless, I left all my code test in place in there something of another case may be useful):

    var inputParameters = new Properties();
    inputParameters.put("name", name);
    System.log("name '" +name);
    System.log("hostResource '" +hostResource);
    var curToken = wf.execute(inputParameters); //,"root","vmware");
    while (curToken.state == "running"){
        System.log(".. still running ..");
        System.sleep(1000);
    }
    var tokens = wf.executions;
    // Each execution is a "workflowToken" object
    for each (token in tokens){
        if (token.id == curToken.id && token.isStillValid){
            System.log("");
            System.log("=============== Checking token ===============");
            System.log("Token ID: "+token.id);
            System.log("Start Date: "+token.startDate);
            if(token.endDate != null){
                System.log("End Date: "+token.endDate);
            }
            System.log("Business State: "+token.businessState); // Indicates the business state as defined by the workflow dev in each of the elements of the workflow (not always specified)
            System.log("State: "+token.state); // Indicates the system state of this workflow
            /* State values are likely to be one of the following:
            waiting <- waiting for user input
            failed <- an exception was thrown to cause the workflow to fail
            completed <- workflow competed running successfully
            canceled <- user right-clicked and canceled the workflow
            running <- workflow is still processing
            */
            System.log("");
            System.log("==== Token Inputs ====");
            var inputParams = token.getInputParameters();
            if (inputParams != null){
                for each (key in inputParams.keys){
                    var value = inputParams.get(key);
                    System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
                }
            }
            System.log("");
            System.log("==== Token Attributes ====");
            var attributes = token.getAttributes();
            if(attributes != null){
                for each (key in attributes.keys){
                    var value = attributes.get(key);
                    System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
                }
            }
    
            System.log("");
            System.log("==== Token Outputs ====");
            var outputParams = token.getOutputParameters();
            if (outputParams != null){
                for each (key in outputParams.keys){
                    var value = outputParams.get(key);
                    System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
                }
            }
    
            System.log("");
            System.log("==== Token Log Events ====");
            var logEvents = new Array();
            logEvents = token.logEvents;
            var eventCount = logEvents.length;
            System.log("Event Count: "+eventCount);
            for (i=eventCount-1; i>-1; i--){
                var logEvent = logEvents[i];
                System.log("");
                System.log(" == EVENT ENTRY "+(eventCount - i)+" == ");
                System.log("logTimeStamp: "+logEvent.logTimeStamp);
                System.log("longDescription: "+logEvent.longDescription);
                System.log("originatorId: "+logEvent.originatorId);
                System.log("originatorUri: "+logEvent.originarorUri);
                System.log("originatorUserName: "+logEvent.originatorUserName);
                System.log("severity: "+logEvent.severity);
                System.log("shortDescription: "+logEvent.shortDescription);
            }
        }
    }
    

    And to get an idea of the output, my tab newspapers looked like this:

    [2014-08-01 16:29:25.632] [I] name 'demo
    [2014-08-01 16:29:25.632] [I] hostResource 'null
    [2014-08-01 16:29:26.351] [I] .. still running ..
    [2014-08-01 16:29:27.365] [I]
    [2014-08-01 16:29:27.365] [I] =============== Checking token ===============
    [2014-08-01 16:29:27.365] [I] Token ID: ff80808146af57140147934349c10567
    [2014-08-01 16:29:27.365] [I] Start Date: 2014-08-01 16:29:26
    [2014-08-01 16:29:27.365] [I] End Date: 2014-08-01 16:29:26
    [2014-08-01 16:29:27.365] [I] Business State: null
    [2014-08-01 16:29:27.367] [I] State: completed
    [2014-08-01 16:29:27.367] [I]
    [2014-08-01 16:29:27.367] [I] ==== Token Inputs ====
    [2014-08-01 16:29:27.371] [I] name: demo (string)
    [2014-08-01 16:29:27.371] [I]
    [2014-08-01 16:29:27.371] [I] ==== Token Attributes ====
    [2014-08-01 16:29:27.374] [I] restOperation: null (null)
    [2014-08-01 16:29:27.374] [I] statusCodeAttribute: null (null)
    [2014-08-01 16:29:27.374] [I] snapshotids: null (null)
    [2014-08-01 16:29:27.374] [I] RESTHost: null (null)
    [2014-08-01 16:29:27.375] [I] hostResource: null (null)
    [2014-08-01 16:29:27.375] [I] errorCode:  (string)
    [2014-08-01 16:29:27.375] [I]
    [2014-08-01 16:29:27.375] [I] ==== Token Outputs ====
    [2014-08-01 16:29:27.378] [I] snapshots: 1966,2262,2555,2927,3272,3586,3895,3903,3909,3987,4041,4430,4734,5048 (Array)
    [2014-08-01 16:29:27.378] [I]
    [2014-08-01 16:29:27.378] [I] ==== Token Log Events ====
    [2014-08-01 16:29:27.423] [I] Event Count: 2
    [2014-08-01 16:29:27.423] [I]
    [2014-08-01 16:29:27.423] [I]  == EVENT ENTRY 1 ==
    [2014-08-01 16:29:27.423] [I] logTimeStamp: 2014-08-01 16:29:26.364
    [2014-08-01 16:29:27.423] [I] longDescription: Workflow has started
    [2014-08-01 16:29:27.423] [I] originatorId: a4e950d3-c575-4ddd-8b7f-dd838cdf7b2e
    [2014-08-01 16:29:27.423] [I] originatorUri: undefined
    [2014-08-01 16:29:27.423] [I] originatorUserName: bazbill
    [2014-08-01 16:29:27.424] [I] severity: 0
    [2014-08-01 16:29:27.424] [I] shortDescription: Workflow has started
    [2014-08-01 16:29:27.424] [I]
    [2014-08-01 16:29:27.424] [I]  == EVENT ENTRY 2 ==
    [2014-08-01 16:29:27.424] [I] logTimeStamp: 2014-08-01 16:29:26.401
    [2014-08-01 16:29:27.424] [I] longDescription: Workflow is completed
    [2014-08-01 16:29:27.424] [I] originatorId: a4e950d3-c575-4ddd-8b7f-dd838cdf7b2e
    [2014-08-01 16:29:27.424] [I] originatorUri: undefined
    [2014-08-01 16:29:27.425] [I] originatorUserName: bazbill
    [2014-08-01 16:29:27.425] [I] severity: 0
    [2014-08-01 16:29:27.425] [I] shortDescription: Workflow is completed
    

Maybe you are looking for

  • s3620f flash drive problem.

    Device Manager, it says that compact flash can not be loaded because of unfinished or damage. So I can't use my USBs to add more songs on my ipod. can someone help me solve this problem? Thank you.

  • Satellite A660 - Keep the downloaded movies freeze

    Hi allThis is my first thread so apologies if it doesn't make much sense. I have an A660 Satellite that I bought at Christmas (still in warranty) that began to play up when I look at the downloaded movies. This has only just begun in 1-2 months, but

  • Same contacts 2 iClouds

    Hello: I created 2 accounts to save new contacts into my new iPhone. With my new account, I have contacts in the other account I don't know what I did wrong, I signed ITunes Store with the other account. Sorry for my English

  • HP Pavilion dv7-3173nr: HP Recovery Manager

    2 weeks ago, I bought this laptop second hand from a friend of my Cousin. It does so any disk from HP. I got was the laptop & charger. I decided to upgrade to Windows 10 & the laptop was working fine, but I couldn't because my recovery (Partition) wa

  • iOS 9 runs very slowly

    Hello I have a problem with my iPhone 5 since I have updated to iOS 9 and later versions.The software runs very slowly unlike iOS 8.4.1. What can I do? Is it possible to recover the 8.4.1 iOS?And if not, how can I do to run faster? Thanks for your he