Scripts/Get-NFSv3ExtendedGroups.ps1
<#
.SYNOPSIS Lists NFSv3 extended groups stored in Azure DB. .DESCRIPTION This command lists NFSv3 extended groups stored in Azure DB for all the Uids. If Uid is provided, it will just list the groups for that Uid. .PARAMETER ResourceGroupName The name of the Resource Group in Azure where the storage account resides. .PARAMETER StorageAccountName The name of the Azure storage account. .PARAMETER Uid Optional, Uid of user whose supplementary groups needs to listed. .EXAMPLE Get-NFSv3ExtendedGroups -ResourceGroupName "MyRG" -StorageAccountName "MyStorage" -Uid "1001" .NOTES Written by: [Azure Blob NFS] Date: [October 10, 2024] #> function Get-NFSv3ExtendedGroups{ [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$ResourceGroupName, [Parameter(Mandatory=$true)] [string]$StorageAccountName, [Parameter(Mandatory=$false)] [string]$Uid ) $prefix = "nfsv3_" if ($PSBoundParameters.ContainsKey($Uid)) { if ([string]::IsNullOrEmpty($Uid)) { Write-NFSv3ExtendedGroupsLog -Message "Uid can not be null or empty." -LogLevel "ERROR" } # Get specific user if $Uid is provided. $userName = $prefix + $Uid # Get localuser with given UID from storage server. $user = Get-AzStorageLocalUser -ResourceGroupName $ResourceGroupName -StorageAccountName $StorageAccountName -UserName $userName $user.ExtendedGroups -join ", " } else { # List all the users if $Uid is not provided. # Get all the LocalUsers from storage server for the given account. $users = Get-AzStorageLocalUser -ResourceGroupName $ResourceGroupName -StorageAccountName $StorageAccountName -IncludeNFSv3 $users | Select-Object @{ Name = 'Uid' Expression = { $_.Name -replace "^$prefix", "" } }, @{ Name = 'ExtendedGroups' Expression = { $_.ExtendedGroups -join ", " } } | Format-Table -AutoSize } } |