Microsoft Virtualization Discussions

Get-NaQuotaReport : .QuotaUsers => Cannot index into a null array

storagedp
2,795 Views

Hello,

I'm trying to generate some reports of quota usage using function Get-NaQuotaReport. I would like to generate the same output as "quota report -x" command.

It works perfectly with an ONTAP system 7.x system but I get an error message on 8.x system (tested on 8.0.2P3 with Toolkit 1.7 + PS 2.0) indicating that QuotaUsers array is null when the current quota object correspond to a "Tree" or a default user quota (* user@/vol/...).

No problem with "User"quotas, QuotaUsers return a valid array for them

Cannot index into a null array.

At line:1 char:51

+ Get-NaQuotaReport | ForEach-Object {$_.QuotaUsers[ <<<< 0].QuotaUserId}

    + CategoryInfo          : InvalidOperation: (0:Int32) [], RuntimeException

    + FullyQualifiedErrorId : NullArray

Command used to reproduce the problem : Get-NaQuotaReport | ForEach-Object {$_.QuotaUsers[0].QuotaUserId}

Regards,

1 REPLY 1

cknight
2,795 Views

Data ONTAP doesn't always return the QuotaUsers field.  So you should check that QuotaUsers is present before using it.

Public