PowerCLI

 View Only
Expand all | Collapse all

Get-datastore not working at all

  • 1.  Get-datastore not working at all

    Posted Jun 11, 2012 08:14 AM

    Hi all

    Apologies if something similar has been posted elsewhere, but I'm getting pretty desperate.

    We're trying to get some datastore readings back from a VCenter (VSphere?) instance, able to get everything back except for anything datastore related. I'm not sure if it could be due to permissions, but seeing as I'm able to get any other reading back, I kind of doubt it. If it is permissions that would actually make my life considerably simpler, but on to the info:

    Using PowerCLI, I'm able to connect to a VCenter isntance. If I do, say, get-inventory, that works fine. if I do get-datastore however, I get this:

    Get-Datastore : 11/06/2012 10:04:24    Get-Datastore        Object reference not set to an instance of an object.
    At line:1 char:14
    + get-datastore <<<<
        + CategoryInfo          : NotSpecified: (:) [Get-Datastore], VimException
        + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio   n.ViCore.Cmdlets.Commands.GetDatastore

    I've tried different combos of this as well, like:

    get-vmhost -name <NAME_OF_ESX_SERVER> | get-datastore

    I've also tried using Python, error being more or less similar to the above.

    At this point, I'm inclined to say that the datastore stats just aren't available for whatever reason, but as to why I have no idea. I'm not the admin on the VMWare side of things, I'm just trying to implement some monitoring for it.

    Can anyone perhaps suggest anything we might need to try? Should the user I use to connect with perhaps be granted admin or admin-like rights? Should I try a different command? Different version of PowerCLI (using PowerCLI Component 5.0 build 544967)?

    The ESX version I believe is VMware ESXi 4.1.0 build-381591.

    Any help at all will be greatly appreciated.



  • 2.  RE: Get-datastore not working at all

    Posted Jun 11, 2012 08:20 AM

    That problem has been reported before, see here.

    Can you try with an older PowerCLI version (4.1.x) ?



  • 3.  RE: Get-datastore not working at all

    Posted Jun 11, 2012 08:21 AM

    I'll give that a go quick, should hopefully know in a couple of minutes. Thanks for the help so far, appreciate it.



  • 4.  RE: Get-datastore not working at all

    Posted Jun 11, 2012 09:33 AM

    OK, version 4 at least doesn't give me any errors when I run get-datastore. Problem is it still doesn't return anything, though not sure if I'm supposed to run get-datastore with any additional parameters though.

    I'll do some more digging around, thanks for the help with this.



  • 5.  RE: Get-datastore not working at all

    Posted Jun 11, 2012 09:36 AM

    Without extra parameters, the Get-Datastore cmdlet should return all datastores you are entitled to see.

    Could be a permission problem of the account you are using.

    Can you see the datastores from the vSphere client with that account ?



  • 6.  RE: Get-datastore not working at all

    Posted Jun 11, 2012 09:41 AM

    Not too sure, unfortunately don't have access to a vSphere client just yet. I'll get in touch with the admin and ask if he could maybe temporarily give the account I'm testing with admin rights just to see if we get some more stats back. If it works, the admin could probably just give us special rights for certain objects I'm guessing.

    I'll post back any updates once we've gotten something more, but in the meantime I think you solved my main problem :smileyhappy:

    Thanks again for the quick and thorough help, really appreciate it.



  • 7.  RE: Get-datastore not working at all

    Posted Jun 12, 2012 11:17 AM

    Quick update, still no luck so far unfortunately :smileysad:

    I checked with the VM admin, the user I'm using definitely has full admin access. When I run get-datastore however, I still get absolutely nothing at all.

    Could it be that these readings have been disabled somehow, or that the rights are just so strict that not even an admin user has access to it? Apologies if I sound ignorant, but I'm not too clued up with the VMWare side of things.

    Whatever the case may be, I'm now relatively sure that the problem isn't on the client side of things.



  • 8.  RE: Get-datastore not working at all

    Broadcom Employee
    Posted Jun 12, 2012 11:24 AM

    Hi,

    Can you provide the error details of the cmdlet exception using following commands:

    $error[0].Exception | select *

    $error[0].Exception.InnerException | select *

    It may help us find out the reason for this strange behavior.

    Thanks,

    Yasen



  • 9.  RE: Get-datastore not working at all

    Posted Jun 12, 2012 11:52 AM

    Hi Yasen

    Thanks for the reply. Not sure if I did this correctly, but no exceptions from the look of things:

    [vSphere PowerCLI]  Connect-VIServer vcenter.myserver.com

    Name                           Port  User
    ----                           ----  ----
    vcenter.myserver.com           443   mydomain\myuser


    [vSphere PowerCLI]  get-datastore
    [vSphere PowerCLI]  $error[0].Exception | select *
    [vSphere PowerCLI]  $error[0].Exception.InnerException | select *
    [vSphere PowerCLI]

    Just to make sure I'm connected and able to query at least something:

    [vSphere PowerCLI]  get-inventory

    Name                           Type                 Id
    ----                           ----                 --
    Hosts & Clusters               Folder               Folder-group-d1
    ***************                Datacenter           Datacenter-d...
    ********                       Datacenter           Datacenter-d...
    datastore                      Folder               Folder-group...
    host                           Folder               Folder-group...
    vm                             Folder               Folder-group...
    datastore                      Folder               Folder-group...
    *******_host                   Folder               Folder-group-h3
    *******_vm                     Folder               Folder-group-v4
    *****                          Folder               Folder-group...
    *******                        Cluster              ClusterCompu...
    ****                           VirtualMachine       VirtualMachi...
    *********                      VirtualMachine       VirtualMachi...
    **********                     VirtualMachine       VirtualMachi...
    Windows                        Folder               Folder-group...
    Resources                      ResourcePool         ResourcePool...
    ***********************        VMHost               HostSystem-h...
    ***********************        VMHost               HostSystem-h...
    ***********************        VMHost               HostSystem-h...
    System Support                 Folder               Folder-group...
    ********                       Folder               Folder-group...
    *************                  VirtualMachine       VirtualMachi...


    [vSphere PowerCLI]

    EDIT: Just to add, I tried different combos of get-datastore as well, all just coming back with nothing. Commands varied from something like this (can't remember the exact syntax in each case):

    get-datastore -vmhost vmhost1.mydomain.com

    get-vmhost vmhost1.mydomain.com | get-datastore (not sure about this one, could've been different)

    Could it be that the config on the VMWare side is just something out of the ordinary? I'm well and truly stumped here.



  • 10.  RE: Get-datastore not working at all

    Posted Jun 12, 2012 01:43 PM

    I might just be grasping at straws at this stage, but could this perhaps have something to do with it?

    [vSphere PowerCLI] Get-VMHost | Get-VMHostStorage

    Id                             SoftwareIScsiEnabled
    --                             --------------------
    HostStorageSystem-storageSy... False
    HostStorageSystem-storageSy... False
    HostStorageSystem-storageSy... False


  • 11.  RE: Get-datastore not working at all

    Posted Jun 12, 2012 03:39 PM

    I'm afraid that just says that software ISCSI is not enabled.



  • 12.  RE: Get-datastore not working at all

    Posted Jun 13, 2012 06:51 AM

    Hi LucD

    Thanks for that. It doesn't seem like I'm going to come right with the datastore readings unfortunately. I was thinking of just getting a temporary test VSphere environment going in order to see if I can duplicate this behaviour somehow, but I do not have the required resources unfortunately.

    I'll pass this back to the VM admin to chase up on his side for now.



  • 13.  RE: Get-datastore not working at all

    Posted Jul 03, 2012 09:18 PM

    I'm seeing the same issue (exact same error). My colleague (who has more privileges) does not get the error, so I'm thinking it is a permissions problem, even though the error message doesn't indicate it.



  • 14.  RE: Get-datastore not working at all

    Posted Jan 07, 2013 12:00 AM

    Hi guys,

    I got the same error and I'm using PowerCLI version 5.0.1.  I can see datastores from the vSphere client. If I execute Get-datastore with admin privileges, I won't have this problem.  Just wonder what exactly roles/privileges is required?

    Thanks

    puyo



  • 15.  RE: Get-datastore not working at all

    Posted Jan 07, 2013 09:03 AM

    Can you check what exeception was returned ?

    See Yasen's instructions in this thread.



  • 16.  RE: Get-datastore not working at all

    Posted Jan 08, 2013 12:03 AM

    Here is the error message:

    Get-Datastore : 8/01/2013 11:00:22 AM    Get-Datastore        Object reference not set to an instance of an object.
    At .\MigrateDatastore.ps1:103 char:16
    +   Get-Datastore <<<<  | Foreach-Object {write-host($_.Name)}
        + CategoryInfo          : NotSpecified: (:) [Get-Datastore], VimException
        + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastore

    ErrorId           : Core_BaseCmdlet_UnknownError
    ErrorCategory     : NotSpecified
    TargetObject      :
    RecommendedAction :
    SessionId         :
    ConnectionId      : /VIServer=prod\svc-ausbuilds@melradvcw01.prod.quest.corp:443/
    Severity          : Error
    Message           : 8/01/2013 11:00:22 AM    Get-Datastore        Object reference not set to an instance of an object.
    Data              : {ParameterValues}
    InnerException    : System.NullReferenceException: Object reference not set to an instance of an object.
                           at VMware.VimAutomation.ViCore.Impl.V1.Service.DatastoreServiceImpl.GetDatacenterDatastoreList()
                           at VMware.VimAutomation.ViCore.Impl.V1.Service.StorageServiceImpl.<GetDatastoreStream>d__0.MoveNext()
                           at VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastoreWorker.DoWork(List`1 moList)
                           at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.CmdletWorker.DoWork(List`1 moList)
                           at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.CmdletWorker.StartWork(Object obj)
    TargetSite        :
    StackTrace        :
    HelpLink          :
    Source            :

    Message        : Object reference not set to an instance of an object.
    Data           : {}
    InnerException :
    TargetSite     : System.Collections.Generic.Dictionary`2[System.String,VMware.VimAutomation.ViCore.Interop.V1.VIObjectInterop] GetDatacenterDatastoreList()
    StackTrace     :    at VMware.VimAutomation.ViCore.Impl.V1.Service.DatastoreServiceImpl.GetDatacenterDatastoreList()
                        at VMware.VimAutomation.ViCore.Impl.V1.Service.StorageServiceImpl.<GetDatastoreStream>d__0.MoveNext()
                        at VMware.VimAutomation.ViCore.Cmdlets.Commands.GetDatastoreWorker.DoWork(List`1 moList)
                        at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.CmdletWorker.DoWork(List`1 moList)
                        at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.CmdletWorker.StartWork(Object obj)
    HelpLink       :
    Source         : VMware.VimAutomation.ViCore.Impl



  • 17.  RE: Get-datastore not working at all

    Posted Jan 08, 2013 08:30 AM

    Are you running this from a PowerShell v3 engine ?

    Do a

    $psversiontable

    The current PowerCLI version does not support PowerShell v3, can you try to run the script from a PowerShell v2 installation.

    There are some known issues, and starting with

    powershell -version 2.0

    doesn't always seem to help.



  • 18.  RE: Get-datastore not working at all

    Posted Jan 09, 2013 01:54 AM

    PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $psversiontable

    Name                           Value
    ----                           -----
    CLRVersion                     2.0.50727.5466
    BuildVersion                   6.1.7601.17514
    PSVersion                      2.0
    WSManStackVersion              2.0
    PSCompatibleVersions           {1.0, 2.0}
    SerializationVersion           1.1.0.1
    PSRemotingProtocolVersion      2.1

    I don't think this is environment issue.  If ESX administrator granted me top permission (admin), I won't have this error.  I think this error relate to  permission/roles settings but I'm not sure what.

    Thanks for your help anyway



  • 19.  RE: Get-datastore not working at all

    Posted Nov 06, 2013 04:49 AM

    did you end up getting this to work?