Hi,
You are correct and appologies for the delayed response, I think there is a BUG with the "netgroups-file-get-iter" ZAPI when used with the tag mechanism as it does not return more than 20 returns. I confirmed this by testing another ZAPI "qtree-list-iter" using the tag mechanism to iterate through the results and it works successfully. EG:
<#'-----------------------------------------------------------------------------
'Script Name : GetQtrees.ps1
'Author : Matthew Beattie
'Email : mbeattie@netapp.com
'Created : 2016-08-02
'Description : This script invokes the "qtree-list-iter" ZAPI to enumerate
' : and iterate through a list of qtrees in a volume on a vserver.
'-----------------------------------------------------------------------------#>
param(
[Parameter(Mandatory = $True, HelpMessage = "The name of the cluster")]
[String]$ClusterName,
[Parameter(Mandatory = $False, HelpMessage = "The name of the vserver")]
[String]$VserverName,
[Parameter(Mandatory = $False, HelpMessage = "The name of the volume")]
[String]$VolumeName
)
#'------------------------------------------------------------------------------
#'Initialization Section. Define Global Variables.
#'------------------------------------------------------------------------------
[String]$scriptPath = Split-Path($MyInvocation.MyCommand.Path)
[String]$scriptSpec = $MyInvocation.MyCommand.Definition
[String]$scriptBaseName = (Get-Item $scriptSpec).BaseName
[String]$scriptName = (Get-Item $scriptSpec).Name
[String]$fileSpec = "$scriptPath\ManageOntap.dll"
#'------------------------------------------------------------------------------
#'Ensure the ManageONTAP.dll file exists in the scripts working directory.
#'------------------------------------------------------------------------------
If(-Not(Test-Path -Path $fileSpec)){
Write-Warning "The file ""$fileSpec"" does not exist. Exiting"
Exit
}
#'------------------------------------------------------------------------------
#'Load the ManageONTAP.dll file
#'------------------------------------------------------------------------------
Try{
[Reflection.Assembly]::LoadFile($fileSpec) | Out-Null
Write-Host "Loaded file ""$fileSpec"""
}Catch{
Write-Warning -Message $("Failed loading file ""$fileSpec"". Error " + $_.Exception.Message)
Exit -1
}
#'------------------------------------------------------------------------------
#'Create a ZAPI connection to the cluster using ZAPI version 1.31 (required for netgroups).
#'------------------------------------------------------------------------------
[NetApp.Manage.NaServer]$naServer = New-Object NetApp.Manage.NaServer($ClusterName, "1", "31")
#'------------------------------------------------------------------------------
#'Enuemate credentials to connect ot the cluster.
#'------------------------------------------------------------------------------
$credentials = $host.ui.PromptForCredential("Connect to ""$ClusterName""", "Please enter the user name and password", "", "")
#'------------------------------------------------------------------------------
#'Enumerate the username and password from the PowerShell credential object.
#'------------------------------------------------------------------------------
[String]$domain = $credentials.GetNetworkCredential().domain
[String]$user = $credentials.GetNetworkCredential().username
[String]$password = $credentials.GetNetworkCredential().password
If($domain -ne "" -Or $domain -ne $Null){
If($domain.Contains(".")){
[String]$userName = "$user`@$domain"
}Else{
If($credentials.UserName.Contains("\") -And $credentials.UserName.SubString(0, 1) -ne "\"){
[String]$userName = $credentials.UserName
}Else{
[String]$userName = $user
}
}
}
#'------------------------------------------------------------------------------
#'Set the username and password for the NaServer object.
#'------------------------------------------------------------------------------
$naServer.SetAdminUser($userName, $password)
$naServer.ServerType = 'FILER'
$naServer.TransportType = 'HTTPS'
#'------------------------------------------------------------------------------
#'Invoke the ZAPI to list the netgroups
#'------------------------------------------------------------------------------
[String]$zapiName = "qtree-list-iter"
[String]$tag = "start"
Write-Host "Invoking ZAPI ""$zapiName"""
Write-Host "QtreeName"
While($tag){
$api = New-Object NetApp.Manage.NaElement("$zapiName")
$xi1 = New-Object NetApp.Manage.NaElement("query");
$api.AddChildElement($xi1);
$xi2 = New-Object NetApp.Manage.NaElement("qtree-info");
$xi1.AddChildElement($xi2);
$xi2.AddNewChild("vserver", $VserverName);
$xi2.AddNewChild("volume", $volumeName);
If($tag -ne "start"){
$api.AddNewChild("tag", $tag)
}
Try{
$results = $NaServer.InvokeElem($api)
}Catch{
Write-Warning -Message $("Failed invoking ""$zapiName"". Error " + $_.Exception.Message)
Exit -1
}
$tag = $results.GetChildContent("next-tag")
$records = $results.GetChildContent("num-records")
Write-Host "There are $records records in the current iteration"
If($results -ne $Null -And $records -ne 0){
ForEach($result in ($results.GetChildByName("attributes-list").GetChildren())){
[String]$qtreeName = $result.GetChildContent("qtree")
Write-Host $qtreeName
}
}Else{
Write-Host "There were $records records in the iteration"
}
}
Write-Host "Done"
#'------------------------------------------------------------------------------
Example output:
PS C:\Scripts\PowerShell\Projects> cd .\Qtrees
PS C:\Scripts\PowerShell\Projects\Qtrees> .\Qtrees.ps1 -ClusterName cluster3 -VserverName testnfs1 -VolumeName testvol1
Loaded file "C:\Scripts\PowerShell\Projects\Qtrees\ManageOntap.dll"
Invoking ZAPI "qtree-list-iter"
QtreeName
There are 20 records in the current iteration
qtree_01
qtree_02
qtree_03
qtree_04
qtree_05
qtree_06
qtree_07
qtree_08
qtree_09
qtree_10
qtree_11
qtree_12
qtree_13
qtree_14
qtree_15
qtree_16
qtree_17
qtree_18
qtree_19
There are 20 records in the current iteration
qtree_20
qtree_21
qtree_22
qtree_23
qtree_24
qtree_25
qtree_26
qtree_27
qtree_28
qtree_29
qtree_30
qtree_31
qtree_32
qtree_33
qtree_34
qtree_35
qtree_36
qtree_37
qtree_38
qtree_39
There are 11 records in the current iteration
qtree_40
qtree_41
qtree_42
qtree_43
qtree_44
qtree_45
qtree_46
qtree_47
qtree_48
qtree_49
qtree_50
Done
Now if i apply exactly the same principle using the tag mechanism but using the "netgroups-file-get-iter" it will only show the first 20 results (even though there were 25 netgroups on my vserver). EG
<#'-----------------------------------------------------------------------------
'Script Name : NetGroups.ps1
'Author : Matthew Beattie
'Email : mbeattie@netapp.com
'Created : 2016-08-02
'Description : This script invokes the "netgroups-get-iter" ZAPI to enumerate
' : and iterate through a list of netgroups on a vserver
'-----------------------------------------------------------------------------#>
param(
[Parameter(Mandatory = $True, HelpMessage = "The name of the cluster")]
[String]$ClusterName,
[Parameter(Mandatory = $False, HelpMessage = "The name of the vserver")]
[String]$VserverName
)
#'------------------------------------------------------------------------------
#'Initialization Section. Define Global Variables.
#'------------------------------------------------------------------------------
[String]$scriptPath = Split-Path($MyInvocation.MyCommand.Path)
[String]$scriptSpec = $MyInvocation.MyCommand.Definition
[String]$scriptBaseName = (Get-Item $scriptSpec).BaseName
[String]$scriptName = (Get-Item $scriptSpec).Name
[String]$fileSpec = "$scriptPath\ManageOntap.dll"
#'------------------------------------------------------------------------------
#'Ensure the ManageONTAP.dll file exists in the scripts working directory.
#'------------------------------------------------------------------------------
If(-Not(Test-Path -Path $fileSpec)){
Write-Warning "The file ""$fileSpec"" does not exist. Exiting"
Exit
}
#'------------------------------------------------------------------------------
#'Load the ManageONTAP.dll file
#'------------------------------------------------------------------------------
Try{
[Reflection.Assembly]::LoadFile($fileSpec) | Out-Null
Write-Host "Loaded file ""$fileSpec"""
}Catch{
Write-Warning -Message $("Failed loading file ""$fileSpec"". Error " + $_.Exception.Message)
Exit -1
}
#'------------------------------------------------------------------------------
#'Create a ZAPI connection to the cluster using ZAPI version 1.31 (required for netgroups).
#'------------------------------------------------------------------------------
[NetApp.Manage.NaServer]$naServer = New-Object NetApp.Manage.NaServer($ClusterName, "1", "31")
#'------------------------------------------------------------------------------
#'Enuemate credentials to connect ot the cluster.
#'------------------------------------------------------------------------------
$credentials = $host.ui.PromptForCredential("Connect to ""$ClusterName""", "Please enter the user name and password", "", "")
#'------------------------------------------------------------------------------
#'Enumerate the username and password from the PowerShell credential object.
#'------------------------------------------------------------------------------
[String]$domain = $credentials.GetNetworkCredential().domain
[String]$user = $credentials.GetNetworkCredential().username
[String]$password = $credentials.GetNetworkCredential().password
If($domain -ne "" -Or $domain -ne $Null){
If($domain.Contains(".")){
[String]$userName = "$user`@$domain"
}Else{
If($credentials.UserName.Contains("\") -And $credentials.UserName.SubString(0, 1) -ne "\"){
[String]$userName = $credentials.UserName
}Else{
[String]$userName = $user
}
}
}
#'------------------------------------------------------------------------------
#'Set the username and password for the NaServer object.
#'------------------------------------------------------------------------------
$naServer.SetAdminUser($userName, $password)
$naServer.ServerType = 'FILER'
$naServer.TransportType = 'HTTPS'
#'------------------------------------------------------------------------------
#'Invoke the ZAPI to list the netgroups
#'------------------------------------------------------------------------------
[String]$zapiName = "netgroups-file-get-iter"
[String]$tag = "start"
Write-Host "Invoking ZAPI ""$zapiName"""
Write-Host "NetGroupName,Users"
While($tag){
$api = New-Object NetApp.Manage.NaElement("$zapiName")
$xi1 = New-Object NetApp.Manage.NaElement("query");
$api.AddChildElement($xi1);
$xi2 = New-Object NetApp.Manage.NaElement("netgroups-file-config-info");
$xi1.AddChildElement($xi2);
$xi2.AddNewChild("vserver", $VserverName);
If($tag -ne "start"){
$api.AddNewChild("tag", $tag)
}
Try{
$results = $NaServer.InvokeElem($api)
}Catch{
Write-Warning -Message $("Failed invoking ""$zapiName"". Error " + $_.Exception.Message)
Exit -1
}
$tag = $results.GetChildContent("next-tag")
$records = $results.GetChildContent("num-records")
Write-Host "There are $records records in the current iteration"
If($results -ne $Null -And $records -ne 0){
ForEach($result in ($results.GetChildByName("attributes-list").GetChildren())){
[String]$netGroupName = $result.GetChildContent("netgroup-name")
[String]$netGroupUser = $result.GetChildContent("user")
Write-Host "$netGroupName,$netGroupUser"
}
}Else{
Write-Host "There were $records records in the iteration"
}
}
Write-Host "Done"
#'------------------------------------------------------------------------------
Output:
PS C:\Scripts\PowerShell\Projects\NetGroups> .\NetGroups.ps1 -ClusterName cluster3 -VserverName testnfs1
Loaded file "C:\Scripts\PowerShell\Projects\NetGroups\ManageOntap.dll"
Invoking ZAPI "netgroups-file-get-iter"
NetGroupName,Users
There are 20 records in the current iteration
group1,user1
group2,user2
group3,user3
group4,user4
group5,user5
group6,user6
group7,user7
group8,user8
group9,user9
group10,user10
group11,user11
group12,user12
group13,user13
group14,user14
group15,user15
group16,user16
group17,user17
group18,user18
group19,user19
group20,user20
There are 0 records in the current iteration
There were 0 records in the iteration
Done
CLI output
cluster3::> netgroup file show -vserver testnfs1 -fields netgroup,user
vserver netgroup user
-------- -------- --------
testnfs1 group1 user1
testnfs1 group2 user2
testnfs1 group3 user3
testnfs1 group4 user4
testnfs1 group5 user5
testnfs1 group6 user6
testnfs1 group7 user7
testnfs1 group8 user8
testnfs1 group9 user9
testnfs1 group10 user10
testnfs1 group11 user11
testnfs1 group12 user12
testnfs1 group13 user13
testnfs1 group14 user14
testnfs1 group15 user15
testnfs1 group16 user16
testnfs1 group17 user17
testnfs1 group18 user18
testnfs1 group19 user19
testnfs1 group20 user20
testnfs1 group21 user21
testnfs1 group22 user22
testnfs1 group23 user23
testnfs1 group24 user24
testnfs1 group25 user25
25 entries were displayed.
I think this is a BUG with the "netgroups-file-get-iter" ZAPI.
/matt
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.