Private/Get-AzTableSasQueryString.ps1
|
function Get-AzTableSasQueryString { <# .SYNOPSIS Unwraps and normalizes the SAS token stored on an AzTableAPI context. .DESCRIPTION Converts the SecureString SasToken on a context object to a query string guaranteed to start with a single '?'. .OUTPUTS [string] Normalized SAS query string starting with '?'. #> [CmdletBinding()] [OutputType([string])] param ( [Parameter(Mandatory)] [PSCustomObject]$Context ) $rawSas = if ($Context.SasToken -is [System.Security.SecureString]) { [System.Net.NetworkCredential]::new('', $Context.SasToken).Password } else { [string]$Context.SasToken } if ([string]::IsNullOrWhiteSpace($rawSas)) { return '' } if ($rawSas.StartsWith('?')) { return $rawSas } return "?$rawSas" } |