Scripts/RemoveNFSv3ExtendedGroups.ps1
<#
.SYNOPSIS Removes NFSv3 extended groups stored in Azure DB for specific Uid. .DESCRIPTION This command removes NFSv3 extended groups stored in Azure DB for specific 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 Uid of user whose supplementary groups needs to be deleted. .EXAMPLE Remove-NFSv3ExtendedGroups -ResourceGroupName "MyRG" -StorageAccountName "MyStorage" -Uid "1001" .NOTES Written by: [Azure Blob NFS] Date: [October 10, 2024] #> function Remove-NFSv3ExtendedGroups{ [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$ResourceGroupName, [Parameter(Mandatory=$true)] [string]$StorageAccountName, [Parameter(Mandatory=$true)] [string]$Uid ) # logMessage is written in this way to keep the indentation correct in log file. $logMessage = @" Remove-NFSv3ExtendedGroups started, ResourceGroupName : $ResourceGroupName, StorageAccountName : $StorageAccountName, Uid : $Uid "@ Write-NFSv3ExtendedGroupsLog $logMessage -VerbosePreference $VerbosePreference $prefix = "nfsv3_" $userName = $prefix + $Uid # Remove localuser from storage server. try { Remove-AzStorageLocalUser -ResourceGroupName $ResourceGroupName -StorageAccountName $StorageAccountName -UserName $userName -ErrorAction Stop Write-NFSv3ExtendedGroupsLog "Removed LocaclUser entry for Uid: $Uid from Azure Storage server" -VerbosePreference $VerbosePreference } catch { # Kill the script if Remove-AzStorageLocalUser fails. Write-NFSv3ExtendedGroupsLog "Remove-AzStorageLocalUser failed with error: $_" -LogLevel "ERROR" return } Write-NFSv3ExtendedGroupsLog "Remove-AzStorageLocalUser completed" -VerbosePreference $VerbosePreference } |