can you check the following
Param(
[string]$KeyVaultName,
[string]$SecretName,
[string]$StorageAccountName,
[string]$FileShareName
)
# Authenticate with your Automation Account
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Add-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationID $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint -Environment AzureChinaCloud
#Create Snapshot
$keyvaultsecret = (Get-AzKeyVaultSecret -vaultName $KeyVaultName -name $SecretName -AsPlainText)
$context = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $keyvaultsecret
$share = Get-AzStorageShare -Context $context -Name $FileShareName
$shareObj = [Microsoft.Azure.Commands.Management.Storage.Models.PSFileShare]::new($share.ICloudFileShare)
$shareObj.Snapshot()
# Generate Snapshot List
$SnapshotList = Get-AzStorageShare -Context $context | Where-Object {$_.Name -eq $FileShareName -and $_.IsSnapshot -eq $true -and $_.SnapshotTime -lt ([datetime]::UtcNow.AddDays(-4))}
# Delete Snapshots older than 4 days
foreach ($Snapshot in $SnapshotList)
{
Remove-AzStorageShare -Share $Snapshot -Verbose -Force
}