Script to find the 'top 10' VMs consuming disk performance?

We're troubleshooting an issue of storage and I'm looking for a better way to find virtual machines that consume disk peformance.  If I had a wish list, the script would be the 'top 10' VMs with the highest disk throughput and the e/s in the last 24 hours.

Such a script exist?  Any help would be greatly appreciated.

You can try the following one liner

Get-VM | Select Name,
     @{N="AverageIO";
       E={($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).adddays(-1) | Measure-Object -Average -Property Value).Average}} | `
     Sort-Object -Property AverageIO -Descending | Select -First 10

This example uses the metric of disk.usage.average but you can easily use any of the other measures related to the disc.

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • need a script to get the news of VMs who believed map

    Hi guys

    I need a script to get the info of VMs who believed the data center map...

    Like this

    name of the virtual machine

    name of the cluster

    ESXi host ip

    name of the disk... (if it is disk 1 or 2)

    name of the data store

    NNA

    I used the script below, but I am unable to store data name, cluster and host Info

    Get-VM| Get-HardDisk-DiskType "RawPhysical","RawVirtual"| SelectParent,Name,DiskType,ScsiCanonicalName,DeviceName | fl

    Please suggest any modified script to get above information..

    Try like this

    Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" |Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName,  @{N="Datastore";E={$_.Filename.Split(']')[0].TrimStart('[')}},  @{N="VMHost";E={$_.Parent.Host.Name}},  @{N="Cluster";E={Get-Cluster -VM $_.Parent | Select -ExpandProperty Name}}
    
  • To find the Top most parent SQL

    How to find the top most parent SQL. I want to avoid the hierarchical query that shows a high cost to run. Please suggest alternative options to find the parent

    Maybe (when having multiple hierarchy trees) to be adapted to your needs

    Select empno, I

    from (select empno, I

    WCP

    where empno = 7876

    model

    hierarchy of reference on (select employee empno,

    Manager Mgr

    WCP

    )

    dimension (employee)

    measures (Manager)

    main main_model

    size of (0 I)

    measures (empno)

    rules iterate (100) until (empno [iteration_number + 1] is null)

    (

    EmpNo [iteration_number + 1] = hierarchy.manager [empno [iteration_number]]

    )

    )

    where empno is not null

    order by I desc

    EMPNO I
    7839 3
    7566 2
    7788 1
    7876 0

    Concerning

    Etbin

  • Find the top level of a VM folder

    I want to find the name of the top-level folder that contains a virtual machine in a data center and looking for the root tree.

    For example \\datacenter\folder1\folder2\folder3\TestVM

    I try to find as a parameter of the TestVM folder1.

    I need to sort all the VM in our sphere of their top-level folder

    In all cases to do this would be appreciated.

    Also it would be quite in powercli with scripts

    Try something like this

    $vm = Get-VM -Name TestVM$object = $vm.ExtensionData$parent = Get-View $object.Parent
    
    while($parent -is [VMware.Vim.Folder] -and $parent.Name -ne "vm"){    $object = $parent    $parent = Get-View $object.Parent}$object | Select @{N="VM";E={$vm.Name}},    @{N="Top Folder";E={$object.Name}} 
    
  • Find the top 3 travellers per year

    Hello
    I created a single table where I store the ID of the loyalty, road ID as well as the Dates of vol. I have 5 frequent flyers in total and only 2 channels (to keep this small and concise for this exercise). I'm hoping to find the big TOP 3 passenger flight annually.

    The output should be as follows:
    Flight Year   Route ID    Frequent Flyer   Flight Count
    =======================================================
    2005               001              1001              5
    2005               001              1002              3
    2005               001              1003              3
    
    2005               002              1004              7
    2005               002              1005              5
    2005               002              1001              1
    
    2006               001              1002              7
    2006               001              1003              5
    2006               001              1001              1
    
    2006               002              1005             11
    2006               002              1003              1
    2006               002              1004              1
    Script for table
    CREATE TABLE FLIGHTS
      (
        FREQ_FLYER_ID VARCHAR2(4), ROUTE_ID  VARCHAR2(3), FLIGHT_DATE DATE
      );
    INSERT the Script for the table
    -- 1001: 5; 1002: 3; 1003: 3; 1004: 1, 1005: 1
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-JAN-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-FEB-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-MAR-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-APR-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1001','001',to_date('01-MAY-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-JAN-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-FEB-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-MAR-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-APR-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-MAY-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-JUN-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','001',to_date('01-FEB-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','001',to_date('01-MAR-05','DD-MON-RR'));
    
    -- 1001: 1; 1002: 0;  1003: 0, 1004: 7; 1005: 5
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1001','002',to_date('31-JAN-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('31-JAN-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('28-FEB-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('31-MAR-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('30-APR-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('31-MAY-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('30-JUN-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1004','002',to_date('31-JUL-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-APR-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-MAY-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-JUN-05','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-JUL-05','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('31-AUG-05','DD-MON-RR'));
    
    -- 1001: 1; 1002: 7;  1003: 5, 1004: 0; 1005: 0
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1001','001',to_date('01-JAN-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-FEB-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-MAR-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-APR-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-MAY-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-JUN-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1002','001',to_date('01-JUL-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1002','001',to_date('01-AUG-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-APR-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-MAY-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-JUN-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1003','001',to_date('01-JUL-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1003','001',to_date('01-AUG-06','DD-MON-RR'));
    
    -- 1001: 0; 1002: 0;  1003: 1, 1004: 1; 1005: 11
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1003','002',to_date('31-JAN-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1004','002',to_date('28-FEB-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-JAN-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('28-FEB-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-MAR-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('30-APR-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-MAY-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-JUN-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-JUL-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('31-AUG-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('30-SEP-06','DD-MON-RR'));
    insert into flights (freq_flyer_id,route_id,flight_date) values ('1005','002',to_date('31-OCT-06','DD-MON-RR'));
    Insert into FLIGHTS (FREQ_FLYER_ID,ROUTE_ID,FLIGHT_DATE) values ('1005','002',to_date('30-NOV-06','DD-MON-RR'));
    Thanks in advance!

    Hello

    Here's one way:

    WITH     got_r_num   AS
    (
         SELECT    EXTRACT (YEAR FROM TRUNC (flight_date, 'YEAR'))
                                                AS flight_year
         ,       route_id
         ,       freq_flyer_id
         ,       COUNT (*)                   AS flight_count
         ,       RANK () OVER ( PARTITION BY  TRUNC (flight_date, 'YEAR')
                                       ,             route_id
                                 ORDER BY      COUNT (*)     DESC
                          )                  AS r_num
         FROM      flights
         GROUP BY  TRUNC (flight_date, 'YEAR')
         ,            route_id
         ,       freq_flyer_id
    )
    SELECT    *     -- or list all columns except r_num
    FROM       got_r_num
    WHERE       r_num     <= 3
    ORDER BY  flight_year
    ,            route_id
    ,            r_num
    ;
    

    If there be a tie (in other words, if 4 or more people, some with exactly the same number of flights, all can to be in the top 3 for a given year and the road) then the above query will include all the contenders for the top 3. For example, if you add one more line of your sample data:

    Insert into FLIGHTS (FREQ_FLYER_ID, ROUTE_ID, FLIGHT_DATE)
           values          ('1009',         '002',    to_date('30-NOV-2006','DD-MON-YYYY'));
    

    Now, who are the top 3 flliers for 2006 on road '002'? Obviously, "1005" is one of them, but there is a tie of 3 - way for second place: '1003 ', '1004' and ' 1009' have exactly 1 flight, and all have equal calim to be in the top 3. Why would you exclude one of them, ratehr than the other two? The query above includes all the.
    If you want to ensure that not more than 3 rows are included for the whole year and the road, and then add the columns of tiebreaker to analytical ORDER BY clause and/or use ROW_NUMBER instead of RANK.

    This is called a Query Top - N , because you're gathering of N (N = 3 in this case) from the top of an ordered list.

    Published by: Frank Kulash, December 17, 2012 12:52

  • Script to find the virtual computer off for more than 7 days

    Guys,

    I need a bit help I'm looking for a script that finds all the VMs who have been turned off for more than 7 days.  I would like also the names of those VM and how many days they have been turned off for a worksheet excel output.

    Thanks in advance.

    Sorry, my mistake.

    The correct script is now attached to the previous response

  • script to find the local TSM and TSM remote is activated on the esxi host

    Need to generate scripts to find on which esxi host in the vcenter is enabled for Local TSM and TSM remote...

    Hello, nareshunik-

    Thanks to the handy Get-VMHostService cmdlet, you can quite easily get this info:

    Get-VMHost | Get-VMHostService | ?{"TSM","TSM-SSH" -contains $_.Key -and $_.Running} | Select VMHost,Key,Running
    

    The result is something like:

    VMHost    Key      Running
    ------    ---      -------
    myHost01  TSM         True
    myHost02  TSM         True
    myHost05  TSM         True
    myHost05  TSM-SSH     True
    

    TSM is the local service of TSM or "ESXi Shell", and the TSM - SSH service is "SSH".  How does do for you?

  • algorithm to find the top of the parabola

    Use case: mower rejection of common-mode using a programmable potentiometer

    Problem: The performance of each circuit varies greatly and you are looking for best value (lowest CMRR) gives erroneous results. The performance seems to be relatively flat on some circuits, straight on others. Launching in the middle range of the potentiometer and moving upwards or downwards, I compare the measured value after the change of the potentiometer to the last measured value. By doing this I can get for the lowest CMR.

    Setup: entry wave sign 5V 60 Hz on both positive and negative of a differential ADC. The potentiometer is cut and reduces common-mode noise. Go away and the common-mode noise increases.

    Question: I would like to use adjustment curve to calculate the shape of the performance of the CMR. Take several steps (no more than 10 then I hope). Get the x y (x = 0 to 1023 trim adjustment potentiometers, Y = amplitude of the measured signal common-mode). Find the vertex.

    Is this possible and can someone point to an example.  I have not found one.

    A parable is a second order polynomial curve.  The Summit must be the peak value.  The general polynomial Fit.vi to maintain your data. The Coefficients of the polynomial outputs to calculate the location of the tip with a DAB of analytic geometry.

    Edit: Note that you may need to do checks to make sure that your data has not generated any curve as a parable.

    Lynn

  • Need help with script to find the virtual computer by IP

    Looking for a script that will correspond to the vm to IP, but should be able to find several IPS at the same time.

    I put this together from scripts on the net, which works well to search for a single IP address at a time:

    $match_address = Read-Host "enter the IP address to find."

    Get - VM | %{

    $vmips = $_. Guest.IPAddress

    {foreach ($ip in $vmips)

    If ($ip - as $match_address) {}

    "VM found correspondence address: {0}" f $_. Name

    }

    }

    }

    But would need to be able to enter several IP addresses of different subnets in the $match_address and search script for a match for every ip address.

    Could you please try this?

    function search-VMAssociatedToIP {}

    (param

    $ArrayOfIPToCheck

    )

    {in process

    $VMsAndAssociatedIP = get-view - viewtype 'virtualmachine ' | {foreach-object

    $VM = $_

    $_.guest.net | {foreach-object

    $Net = $_

    $_. IpAddress | {foreach-object

    $IpAddress = $_

    $Output = New-Object-Type PSObject-Prop ([ordered] @ {}

    "VM" = $VM. Name

    "NetworkName" = $Net.Network

    "IP address" = $IpAddress

    })

    Return $Output

    }

    }

    }

    $ArrayOfIPToCheck | {foreach-object

    $IPtoCheck = $_

    $VMsAndAssociatedIP | where {$_.} IpAddress - eq $IPtoCheck} | {foreach-object

    $Output = New-Object-Type PSObject-Prop ([ordered] @ {}

    "IpToCheck" = $IPtoCheck

    'VM' = $_. VM

    "NetworkName" = $_.NetworkName

    'IpAddress' = $_. IpAddress

    })

    Return $Output

    }

    }

    }

    }

    $MyArray = "10.0.33.1","10.0.30.11","10.0.20.11","10.0.32.1".

    Search for VMAssociatedToIP - ArrayOfIPToCheck $MyArray | OGV

    Use a table entry.

    First get the IP addresses of all computers installed correctly (only for virtual machines with VMware tools) virtual based on get - view so the collection will be fast.

    Then compare with the PPE provided as input.

  • Foglight - Script to find the cartridges

    Someone at - it a script or something that can display the installed cartridges or cartridge?

    msg = new StringBuilder()

    Server ["CartridgeService"] .getAllCartridges () .each {msg.append(it.getName()).append("\n")}

    return msg.toString)

    That ought to cover it

  • Need help to modify the Script to find the number of vCPU and reservation of memory in VC

    Hello

    Need help to modify the script so that his can person report to the vc all focus level instead of each level of the Cluster.

    Thank you

    KR

    Try this instead:

    $vmsInfo = Get-VM
    #Creating array to place new object
    
    $reportdata = @()
    
    Foreach ($vm in $vmsInfo)
    {
    #Creating new object
    $vmInfo = "" | Select Name, CPUReservationMHz, MemoryReservationGB
    $vmInfo.Name = $vm.Name
    $vmInfo.CPUReservationMHz = $vm.ExtensionData.ResourceConfig.CpuAllocation.Reservation
    $vmInfo.MemoryReservationGB = $vm.ExtensionData.ResourceConfig.MemoryAllocation.Reservation / 1024;
    #Inserting data into new object.
    $reportdata += $vminfo
    }
    $reportdata
    
  • DENSE_RANK and find the top three rows return regardless of their rank.

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

    Hello

    I have the following problem;

    Dense_rank using I've categorized the trees in a plot of height.

    Now I need to filter the first three records by parcel based on the position of the trees, it's complicated by the fact that sometimes two or three of the three tallest trees have the same height.

    Records that I want to use for the parcel number 90001 are tree numbers 4, 5 and 3.

    Records that I want to use for the parcel number 31000 are tree numbers 4, 5, and 3, but rather the number 2 shaft is included.
    select distinct plot_number
         , tree_number
         , tree_height
         , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
      from tst_rank
      order by plot_number, ht_rank asc
    ;
    
    PLOT_NUMBER TREE_NUMBER TREE_HEIGHT HT_RANK
    ----------- ----------- ----------- -------
          31000           4          10       1 
          31000           5          10       1 
          31000           3           3       2 
          31000           2           2       3 
          31000           1           1       4 
          90001           5          20       1 
          90001           4          10       2 
          90001           3           3       3 
          90001           2           2       4 
          90001           1           1       5 
    
     10 rows selected 
    The dense rank function allows me to classify the trees, but then it has accomplished its purpose. The following query is an example of what I want to do - but - I need to access the 3 early accounts after the rankings were made, so the following query is not going to use the collation.
    select plot_number
         , max(decode(ht_rank, '1', tree_height*100)) ht_1
         , max(decode(ht_rank, '2', tree_height*100)) ht_2
         , max(decode(ht_rank, '3', tree_height*100)) ht_3
    from (select distinct plot_number
               , tree_number
               , tree_height
               , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
            from tst_rank
           order by plot_number, ht_rank asc
          )txt  
     group by plot_number
    ;
    
    PLOT_NUMBER HT_1 HT_2 HT_3
    ----------- ---- ---- ----
          31000   10    3    2 
          90001   20   10    3 
    But I want to see;
    PLOT_NUMBER HT_1 HT_2 HT_3
    ----------- ---- ---- ----
          31000   10   10    3 
          90001   20   10    3 
    Anyone have some ideas of what I could do to get there?

    See you soon
    Ben


    Create script to replicate my problem;
    -- drop table tst_rank;
    
    CREATE TABLE TST_RANK
    ( PLOT_NUMBER NUMBER
    , TREE_NUMBER NUMBER
    , TREE_HEIGHT NUMBER
    );
    
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','1', '1');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','2', '2');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','3', '3');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','4', '10');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','5', '10');
    
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','1', '1');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','2', '2');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','3', '3');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','4', '10');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','5', '20');
    
    COMMIT;
    
    /*
    
    select distinct plot_number
         , tree_number
         , tree_height
         , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
      from tst_rank
      order by plot_number, ht_rank asc
    ;
    
    select plot_number
         , max(decode(ht_rank, '1', tree_height)) ht_1
         , max(decode(ht_rank, '2', tree_height)) ht_2
         , max(decode(ht_rank, '3', tree_height)) ht_3
    from (select distinct plot_number
               , tree_number
               , tree_height
               , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
            from tst_rank
           order by plot_number, ht_rank asc
          )txt  
     group by plot_number
    ;
    
    */
    Published by: benton on 9 October 2012 14:45

    Use ROW_NUMBER

    SQL> select plot_number,
      2         max(decode(rn,1,tree_height)) h1,
      3         max(decode(rn,2,tree_height)) h2,
      4         max(decode(rn,3,tree_height)) h3
      5  from(
      6  select plot_number,tree_height,
      7         row_number() over(partition by plot_number order by tree_height desc) rn
      8  from tst_rank)
      9  group by plot_number;
    
    PLOT_NUMBER         H1         H2         H3
    ----------- ---------- ---------- ----------
          31000         10         10          3
          90001         20         10          3
    
  • Need a powershell script to find the PID of VM in an ESX box

    Hello

    I need a powershell script to list out the PID of all virtual machines running in a box of ESX.

    The script should prompt for ESX box name and root password.

    Expected results:

    The virtual computer name.  NEST

    Thanks in advance!

    My mistake, the point (any character) is to eat the rest of the message.

    Try again with

    $mask = [regex]"vmid=(\d+)\s+([\w-]+)"
    

    He accepts what regex esteem alphabetic characters or the hyphen (-).

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Script to find the vmnic assigned to trade

    All the

    Need help please?

    I'm trying to create a script for the list of the vmnic assigned to 'trade' by 'switch' by ESX host and their output to a txt or csv file. I tried to create 'foreach' loops within foreach loops and keep making a hash of it.

    Any help would be greatly appreciated. Need a script that I have a lot of work to do over the weekend and this script would be a boon.

    Thanks in advance

    Munster

    I did the following script. I hope that's what you want:

    Get-VMHost | ForEach-Object {
      $VMHostName = $_.Name
      Get-VirtualSwitch -VMHost $_ | ForEach-Object {
        $vSwitch = $_.Name
        $VMNic = $_.nic
        Get-VirtualPortgroup -VirtualSwitch $_ | ForEach-Object {
          $VirtualPortgroupName = $_.Name
           $objOutput =  "" | Select-Object -Property VMHost,vSwitch,VMnic,VirtualPortGroup
           $objOutput.VMHost = $VMHostName
           $objOutput.vSwitch = $vSwitch
           $objOutput.VMNic = $VMNic
           $objoutput.virtualportgroup = $VirtualPortgroupName
           Write-Output $objOutput
        }
      }
    }
    

    This script produces the following result in my test environment:

    VMHost                        vSwitch                       VMnic                         VirtualPortGroup
    ------                        -------                       -----                         ----------------
    scomp0407.wurnet.nl           vSwitch0                      {vmnic2, vmnic0}              Service Console
    scomp0407.wurnet.nl           vSwitch0                      {vmnic2, vmnic0}              VMkernel
    scomp0407.wurnet.nl           vSwitch0                      {vmnic2, vmnic0}              vSwitch0 AppSpeed
    scomp0407.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              VM installatie vlan 245
    scomp0407.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              VM productie vlan 11
    scomp0407.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              VM productie vlan 3
    scomp0407.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              vSwitch1 AppSpeed
    scomp0408.wurnet.nl           vSwitch0                      {vmnic2, vmnic0}              Service Console
    scomp0408.wurnet.nl           vSwitch0                      {vmnic2, vmnic0}              VMkernel
    scomp0408.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              VM installatie vlan 245
    scomp0408.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              VM productie vlan 11
    scomp0408.wurnet.nl           vSwitch1                      {vmnic1, vmnic3}              VM productie vlan 3
    

    If you want to write the output to a csv file, you can use the Export-CSV cmdlet to write the output to a csv file.

  • find the top shared appl

    How will I know that an appl system has a shared Top APPL?

    Hello

    How will I know that an appl system has a shared Top APPL?

    View post:
    How to find applications are shared or not

    Thank you
    A H E E R X

Maybe you are looking for