How to get a number of LUNs of StorageDeviceInfo property to connect a nomperipherique or DevicePath?

Hello

I'm new in powershell script and I have a basic question. I try to get a number of LUNS on a drive connected to an ESX Server. I want it because I want to add a row to a virtual machine disk but in vsphere, it should be noted the unique device name. So I want to easily identify the rdm LUN to match the number of LUNS with the name of the device in the StorageDeviceInfo property.

Anyone know an easy way to do it?

Thank you

Sylvain

The following script produces a report with the information you need (I think).

$hostStor = Get-VMHost  | Get-VMHostStorage | Get-View

$hba = @{}
$hostSTor.StorageDeviceInfo.HostBusAdapter | %{
     $hba[http://$_.Key|http://$_.Key] = $_
}
$lun = @{}
$hostSTor.StorageDeviceInfo.ScsiLun | %{
     $lun[http://$_.Key|http://$_.Key] = $_
}

$report = @()
$hostStor.StorageDeviceInfo.ScsiTopology.Adapter | %{
     $hbaDevice = $hba[http://$_.Adapter|http://$_.Adapter].Device
     $_.Target | %{
          $targetNumber =  $_.Target
          $_.Lun | %{
               $row = "" | Select hbaDevice, targetNumber, lunNumber, lunDeviceName
               $row.hbaDevice = $hbaDevice
               $row.targetNumber = $targetNumber
               $row.lunNumber = $_.Lun
               $row.lunDeviceName = $lun[http://$_.ScsiLun|http://$_.ScsiLun].DeviceName
               $report += $row
          }
     }
}
$report

Since there are some hooks in the script, I have attached the script as a file as well.

Tags: VMware

Similar Questions

  • How to get the number of LUN to physical RDM assigned to VM?

    Hi people,

    Is it possible to get the LUN ID or number of a RDM physical disk attached to a virtual from Windows using PowerCLI machine?

    Thank you.

    Hi Albert,

    the first PowerCLI script will give the LUN ID or the number of physical RDM disks attached to a virtual machine for ESX 3.5 servers:

    Get-VM | `
    Get-HardDisk | `
    Where-Object {$_.DiskType -eq "RawPhysical"} | `
    Select-Object -Property @{N="VM";E={$_.Parent}},
      @{N="HardDisk";E={$_.Name}},
      @{N="Lun";E={$_.ScsiCanonicalName.Split(":")[-1]}}
    

    The second script PowerCLI will give you the LUN ID or number of a RDM physical disk attached to a virtual machine for 4 ESX servers:

    Get-VM | `
    Get-HardDisk | `
    Where-Object {$_.DiskType -eq "RawPhysical"} | `
    Select-Object -Property @{N="VM";E={$_.Parent}},
      @{N="HardDisk";E={$_.Name}},
      @{N="Lun";E={
        $HardDisk = $_
        $lun = Get-VMHost -VM $_.Parent | `
          Get-ScsiLun -LunType Disk | `
          Where-Object {$_.CanonicalName -eq $HardDisk.ScsiCanonicalName}
        [int](Select-String ":L(?\d+)$" `
            -InputObject $lun.RuntimeName).Matches[0].Groups['lunID'].Value
      }}
    

    Thanks to Luke for his blog post the making of a New VIProperty called Monday who gave me the idea for the regular expression.

    Best regards, Robert

    Post edited by: RvdNieuwendijk

  • How to get serial number in Dell monitor?

    Hello

    How to get serial number in Dell Monitor (model No.: S2240Lc).

    I have only 20-digit S/n.

    Thank you

    Riou...

    As I said, you can't get a service tag. By the article.

    Monitors without a number of service purchased from resellers (Amazon, Best Buy, Buy.com, cost Co, Wal-Mart, Sams, other boutique online, etc.)
    * Based on the start date of date code monitor 20-digit serial number, Dell PPID you monitor for 3 years warranty
    You need to contact Support for your country. Tell them to open the Dell internal only Oracle knowledge Information center
    * In the search space, they should enter PNP13081, and then click search. This opens the article =
    Replacement for Dell monitor and procedure - Dell international policy policy

    The customer is unable to provide a Dell order number or serial number system because the customer bought the monitor from a retailer. The only information that the client has are the PPID number for the monitor. For monitors when there is not an available Dell order number, agents will use the date code embedded in the PPID monitor serial number to determine the beginning of the start of coverage.

    Discussion = the warranty is 3 years from the date of early series PPID embarked on the label.
    Solution = Set up screen replacement against the fake tag.
    * You would provide the following representative data if you need a replacement monitor in this 3-year period:
    Brick or shop online:
    Monitor model:
    Monitor 20 digits alphanumeric serial number PPID:
    [Your]
    E-mail address:
    Name:
    Shipping address:
    Phone number:
    Operating system:
    Video card:
    Video card ports tested:
    Question:
    Performed troubleshooting:
    Monitor the done Factory Reset
    Watch chess self-test Diagnostics and integrated
    * Post more troubleshooting

  • I have a thinkstation with win7pro an OEM installed how to get serial number

    I have a thinkstation with win7pro an OEM installed how to get serial number

    If it's a win7 machine, there should be a sticker.  It is called the product key and is 25 alphanumeric characters in 5 sets of 5.

  • How to get the number of fonts online

    Hi all

    can you give me solution to the following:

    How to get the number of fonts on a line.

    Ex

    BlackBerry Support 'Community' is supported for my career

    in this line, I want to ITALIC for the word 'Community '.

    Font.GetDefault (). Derive from wil give for total line...

    RichTextField does not?

    See this KB article

    http://supportforums.BlackBerry.com/T5/Java-development/format-text-in-a-RichTextField/Ta-p/445038

  • How to get the number of entries in the navigation menu?

    boc.bmp

    How to get the number of entries in the navigation menu? Check the image. What it shows 8 number of customers and 10 products and 10 orders in the list. How to get it?

    --

    Thank you

    Hello

    Create items of the request saying, "CUSTOMERS", "PRODUCTS" and "ORDERS".

    Create the application process that defines these items when loading the page for example

    C1 in select count (*) NTC (of customer_table)

    loop

    : CUSTOMERS: = c1.cnt;

    end loop;

    C1 in select count (*) NTC (of products_table)

    loop

    PRODUCTS: = c1.cnt;

    end loop;

    C1 in select count (*) NTC (of orders_table)

    loop

    : ORDERS: = c1.cnt;

    end loop;

    Components shared Open-> Navigation bar and change:

    In the entry list Label-> customers & CLIENTS.]

  • How to get the IP address of the client when TCP connect on the server

    How to get the IP address of the client when TCP connect on the server.

    The only parameter obtained the login is the login ID.

    I assume you are using "Wait of TCP on the listening port" on the server. This returns the remote address and port (like out in option).

  • How to maximize the number of RDP session for Remote Desktop connections in windows 2008 server?

    1. How to maximize the number of RDP session for Remote Desktop connections in windows 2008 server?
    2. By default, the system says 2. and to not change/increase.
    3. is everything permissible special necessary to buy?
    Hello
     

    Your question of Windows is more complex than what is generally answered in the Microsoft Answers forums as it is related to maximize the number of RDP session for Office remote connections to the server. Appropriate in instances of Windows Server.

    Please post your question in the Forums of Windows Server.

  • How to get the number of bits of Windows?

    Hi all

    How can I get the number of bits of Windows, the application of the LV is running on?

    By using the disabled conditional structure, I can get the number of bits of the application (if it is built in BT 32 or 64), but not the number of bits of windows.

    Thank you

    system variable 'PROCESSOR_ARCHITECTURE '?

  • How to get the number of line of a multi-line string

    It seems that this Panel of string does not provide the tool to get the chain line number,

    Does anyone have the same experience?

    so...

    How to get the line number of a variable string?

    Number of lines

  • How to get the number and the name of the contacts selector

    Hi all

    I got the Contact Picker work but I have no idea how to get the selected telephone number and the name.

    There are attributes that I can put like contactId.value () to retrieve or there is another way?

    Thanks in advance.

    ImageButton{
                        defaultImageSource: "asset:///images/bluebutton.png"
                        onClicked: {
                            contactPicker.open();
                        }
                        attachedObjects: [
                            ContactPicker {
                                id: contactPicker
                                onContactSelected: {
                                    result.text = "You chose contact: " + contactId;
                                }
                            }
                        ]
    
                    }
    
                    Label {
                        id: result
                        text: "You chose contact: "
                    }
    

    Hello

    You can get the contact name and phone number as this,

    ImageButton{
                        defaultImageSource: "asset:///images/bluebutton.png"
                        onClicked: {
                            contactPicker.open();
                        }
                        attachedObjects: [
                            ContactPicker {
                                id: contactPicker
                                onContactSelected: {
                                    result.text = "You chose contact: " + contactId;
    // call a cpp method to get the details
    
    app.getDetails(contactId); } } ] } Label { id: result text: "You chose contact: " }
    

    the CPP code:

    void ContactDetails(ContactId id)
    {
    Contact contact_info = m_contactService->contactDetails(id);
    
        QString firstName = contact_info.firstName();
        QString lastname = contact_info.lastName();
            QList phoneno_list = contact_info.phoneNumbers();
    
        QStringList no_s;
    
        foreach(ContactAttribute attr, phoneno_list)
        {
            no_s << attr.value();
        }
    }
    

    You can get details like this.

    Kind regards

    Naresh Kodumuri.

  • How to get IMEI number with phonegap app by using Javascript?

    Hello

    I suffer on this the last 2 days to get the IMEI number in phonegap app by using javascript.

    I found all things related to Phonegap with Android, but I want to get the IMEI number with phonegap app by using javascript/JQuery according to requirement.

    Could you please give me the process step by step to get the IMEI number with phonegap app with javascript/JQuery?

    Thanks in advance.

    Thank you

    Jayaram

    You can use the cordova-plugin-device plugin for a UUID of the device (this api is the same on iOS, Android,...)

    This isn't exactly the same as the IMEI, but it is unique enough to identify the device, while protecting the privacy of the owner of the phone.

    If you need to get the IMEI, then google is your friend. This [1] was the first result when searching for "imei cordova.

    There's a good stack overflow article here [2] which has the disadvantage of using this value and encourage you to consider other ways to identify users, because users cannot trust your application if you ask for this info. Read the accepted answer.

    [1] GitHub - aquto/cordova-plugin-imei

    [2] http://stackoverflow.com/questions/1972381/how-to-get-the-devices-imei-esn-programmaticall y-android

  • VMware View | PowerCLI | How to get the number of virtual machine in a specific pool-ID

    Hello

    Generally, to get the number of VMS in a pool, I run this command:

    Get-pool | Select Pool_id, @{Name = "NumVM"; Expression = {($_ |)} (Get - DesktopVM). County}} | out-gridview

    But how can I list all the pools and then select the pool I want a county of?

    Maybe something like:

    Select 1 for accounts

    Select 2 for Marketing

    and then County VM just for this pool and immediate where at the output (Out-gridview or Export-CSV)

    Thanks, Julien

    Hi LucD

    I don't understand the line:

    1.. $pools. County | %{
    Write-Host "$_" $Pools [$_ - 1]. Name

    Why do we need the 1...

    Also is the same as get-get-resourcepool pool?

    Thanks, Julien

  • How to get the number in the format "999,999,999.000" in oracle

    Hi friends,
    How can I get the number entered in the format '999,999,999.000 '...
    for example, if my number has 1900, it should give 1,900.000
    If my number is 10000, then it should give me 10,000.000 like this in sql
    is there a function available for this?

    pls help

    Thank you

    Hello

    Check below hope it solves your problem.

    SQL> SELECT TRIM(TO_CHAR(1900, '999,999,999,999,999.99')) FROM DUAL;
    
    TRIM(TO_CHAR(1900,'999,999,999
    ------------------------------
    1,900.00
    SQL> SELECT TRIM(TO_CHAR(10000, '999,999,999,999,999.99')) FROM DUAL;
    
    TRIM(TO_CHAR(10000,'999,999,99
    ------------------------------
    10,000.00
    
    SQL> 
    

    Concerning
    Ameya

  • Requirement of Beeping - how to get the number of combination of several columns

    Hi gurus, Experts and all,.

    Help me please how this code to the BEEP.

    I need to get the number of each combination of 6 columns if the combination is repeated.

    Columns example: number team responsible for Group Type reason
    The example columns: placed Team1 M1 M1 T1 won 2
    GroupA Team1 H2 M2 T1 loss 1
    GroupB Team2 H2 M3 T2 won 1
    GroupB Team2 H3 M3 T2 loss 2

    Thank you very much

    Jean Paul
    BEEP newbie

    Published by: user10955574 on October 28, 2010 20:15

    Published by: user10955574 on October 29, 2010 03:06

    I sent you the file. Check your mailbox.

Maybe you are looking for