Automation

 View Only
Expand all | Collapse all

Storage Path details Power Cli script Need

Sivapb

SivapbJul 03, 2014 03:01 AM

  • 1.  Storage Path details Power Cli script Need

    Posted Jul 03, 2014 02:17 AM

    hi i need output for for below command in excel file as a single powercli script any one help me

    1.  esxcfg-mpath –l

    2.  esxcli storage core path list

    3.  esxcli storage nmp device list



  • 2.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 02:51 AM

    (Get-VMhost VMhostname | Get-esxcli).storage.nmp.device.list() | Export-Csv -path c:\test.csv

    (Get-VMhost VMhostname | Get-esxcli).storage.core.path.list() | Export-Csv -path c:\test.csv



  • 3.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 03:01 AM

    Thanks for reply

    Getting error



  • 4.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 05:07 AM

    I assume you have more than 1 ESXi host in your environment ?

    In that case

    Get-VMHost "*"

    will return more than 1 object, and consequently so will the Get-EsxCli cmdlet.

    But that means that

    (Get-VMhost VMhostname | Get-esxcli)

    is an array, on an array there is no storage method or property.

    You should pass 1 object to the Get-EsxCli cmdlet, something like this for example

    &{Get-VMhost VMhostname | %{

         $esxcli = Get-esxcli -VMHost $_

         $esxcli.storage.nmp.device.list()

    }} | Export-Csv -path c:\test.csv

    Note how the script uses the call operator (&).

    This is because the ForEach (alias '%'), doesn't place any objects on the pipeline, which can be used as input to the Ex[prt-Csv cmdlet.



  • 5.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 05:25 AM

    Yes my infra have more than 1 host

    Getting following Error message

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

    Get-EsxCli : 7/3/2014 10:48:12 AM    Get-EsxCli        Message: An error occurr

    ed while communicating with the remote host.;

    InnerText:

    At C:\Users\\Desktop\storage.ps1:1 char:29

    + (Get-VMhost "*" | Get-esxcli <<<< )

        + CategoryInfo          : NotSpecified: (:) [Get-EsxCli], HostCommunicatio

       n

        + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInst

       ances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEsxCli

    Get-EsxCli : 7/3/2014 10:48:34 AM    Get-EsxCli        Message: An error occurr

    ed while communicating with the remote host.;

    InnerText:

    At C:\Users\\Desktop\storage.ps1:1 char:29

    + (Get-VMhost "*" | Get-esxcli <<<< )

        + CategoryInfo          : NotSpecified: (:) [Get-EsxCli], HostCommunicatio

       n

        + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInst

       ances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEsxCli

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

    i need out put for following commands

    1.  esxcfg-mpath –l

    2.  esxcli storage core path list

    3.  esxcli storage nmp device list



  • 6.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 05:29 AM

    What code are you executing now ?

    From the error it seems you are still using your original code.



  • 7.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 05:36 AM

    (Get-VMhost "*" | Get-esxcli)

    &{Get-VMhost VMhostname | %{

         $esxcli = Get-esxcli -VMHost $_

         $esxcli.storage.nmp.device.list()

    }} | Export-Csv -path c:\test.csv

    above script i'm executing. i want result for how many active path is there in data store. i have more than 600 hosts and 45 vcenter with different data store .



  • 8.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 06:08 AM

    If you want the info for all the ESXi in your environment, do it like this

    &{Get-VMhost | %{

         $esxcli = Get-esxcli -VMHost $_

         $esxcli.storage.nmp.device.list()

    }} | Export-Csv -path c:\test.csv



  • 9.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 06:15 AM

    Thanks got the output

    can you help me out get the output for following command

    esxcfg-mpath –l



  • 10.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 06:32 AM

    Isn't

    $esxcli.storage.core.path.list()

    producing more or less the same output ?

    The list in Replacements for Service Console Commands might come in handy



  • 11.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 07:11 AM

    No. i dint get the output. i need below info in output

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

    esxcfg-mpath -l

    fc.20000024ff01fe35:21000024ff01fe35-fc.500a098080556875:500a098280556875-naa.60a9800042374b63532b427762556a54

       Runtime Name: vmhba2:C0:T1:L20

       Device: naa.60a9800042374b63532b427762556a54

       Device Display Name: NETAPP Fibre Channel Disk (naa.60a9800042374b63532b427762556a54)

       Adapter: vmhba2 Channel: 0 Target: 1 LUN: 20

       Adapter Identifier: fc.20000024ff01fe35:21000024ff01fe35

       Target Identifier: fc.500a098080556875:500a098280556875

       Plugin: NMP

       State: active

       Transport: fc

       Adapter Transport Details: WWNN: 20:00:00:24:ff:01:fe:35 WWPN: 21:00:00:24:ff:01:fe:35

       Target Transport Details: WWNN: 50:0a:09:80:80:55:68:75 WWPN: 50:0a:09:82:80:55:68:75

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



  • 12.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 07:15 AM

    I'm getting that same information with $esxcli.storage.core.path.list()

    Which vSphere version are you running this against ?

    I assume vSphere 5.*



  • 13.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 07:32 AM

    yes. running vsphere 5.X .

    can u give me the complete powercli code for that 'esxcli.storage.core.path.list'

    output will be notepad also ok for me



  • 14.  RE: Storage Path details Power Cli script Need
    Best Answer

    Posted Jul 03, 2014 08:10 AM

    Try like this

    &{Get-VMhost | %{

         $esxcli = Get-esxcli -VMHost $_

         $esxcli.storage.core.path.list()

    }} | Export-Csv -path c:\test.csv



  • 15.  RE: Storage Path details Power Cli script Need

    Posted Jul 03, 2014 08:37 AM

    Many Thanks LucD :smileyhappy:



  • 16.  RE: Storage Path details Power Cli script Need

    Posted Jul 09, 2014 04:19 AM

    Hi Lucd,

         I am getting error after generating the output in csv format

    PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> &{Get-V

    host | %{

    >>      $esxcli = Get-esxcli -VMHost $_

    >>      $esxcli.storage.core.path.list()

    >> }} | Export-Csv -path c:\temp\test.csv

    >>

    Get-EsxCli : 7/8/2014 11:01:54 PM    Get-EsxCli        Esxcli functionality is

    supported for host 'admpls001v.na.corp.cargill.com' only when connected directl

    y to it (not through vCenter connection).

    At line:2 char:26

    +      $esxcli = Get-esxcli <<<<  -VMHost $_

        + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], InvalidArgume

       nt

        + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetEsxCli

       _RequiredDirectEsxConnection,VMware.VimAutomation.ViCore.Cmdlets.Commands.

      GetEsxCli

    You cannot call a method on a null-valued expression.

    At line:3 char:36

    +      $esxcli.storage.core.path.list <<<< ()

        + CategoryInfo          : InvalidOperation: (list:String) [], RuntimeExcep

       tion

        + FullyQualifiedErrorId : InvokeMethodOnNull

    Get-EsxCli : 7/8/2014 11:01:54 PM    Get-EsxCli        Esxcli functionality is

    supported for host 'admpls002v.na.corp.cargill.com' only when connected directl

    y to it (not through vCenter connection).

    At line:2 char:26

    +      $esxcli = Get-esxcli <<<<  -VMHost $_

        + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], InvalidArgume

       nt

        + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetEsxCli

       _RequiredDirectEsxConnection,VMware.VimAutomation.ViCore.Cmdlets.Commands.

      GetEsxCli

    You cannot call a method on a null-valued expression.

    At line:3 char:36

    +      $esxcli.storage.core.path.list <<<< ()

        + CategoryInfo          : InvalidOperation: (list:String) [], RuntimeExcep

       tion

        + FullyQualifiedErrorId : InvokeMethodOnNull

    Get-EsxCli : 7/8/2014 11:05:04 PM    Get-EsxCli        Esxcli functionality is

    supported for host 'admpls030v.na.corp.cargill.com' only when connected directl

    y to it (not through vCenter connection).

    At line:2 char:26

    +      $esxcli = Get-esxcli <<<<  -VMHost $_

        + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], InvalidArgume

       nt

        + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetEsxCli

       _RequiredDirectEsxConnection,VMware.VimAutomation.ViCore.Cmdlets.Commands.

      GetEsxCli

    You cannot call a method on a null-valued expression.

    At line:3 char:36

    +      $esxcli.storage.core.path.list <<<< ()

        + CategoryInfo          : InvalidOperation: (list:String) [], RuntimeExcep

       tion

        + FullyQualifiedErrorId : InvokeMethodOnNull

    Get-EsxCli : 7/8/2014 11:05:04 PM    Get-EsxCli        Esxcli functionality is

    supported for host 'admpls031v.na.corp.cargill.com' only when connected directl

    y to it (not through vCenter connection).

    At line:2 char:26

    +      $esxcli = Get-esxcli <<<<  -VMHost $_

        + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], InvalidArgume

       nt

        + FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetEsxCli

       _RequiredDirectEsxConnection,VMware.VimAutomation.ViCore.Cmdlets.Commands.

      GetEsxCli

    You cannot call a method on a null-valued expression.

    At line:3 char:36

    +      $esxcli.storage.core.path.list <<<< ()

        + CategoryInfo          : InvalidOperation: (list:String) [], RuntimeExcep

       tion

        + FullyQualifiedErrorId : InvokeMethodOnNull

    Thanks

    vmk2014



  • 17.  RE: Storage Path details Power Cli script Need

    Posted Jul 09, 2014 04:41 AM

    It looks as if you are not connected to the ESXi server.

    You can display the content of $global:defaultviserver to check.