Encode-SqlName

Encodes extended characters in SQL Server names to formats usable in PowerShell paths.
Encode-SqlName [-SqlName*] <string> [<CommonParameters>]

Encodes special characters in SQL Server names to formats usable in PowerShell paths. SQL Server delimited identifiers can contain characters not normally supported in PowerShell object names. When using delimited identifiers in SQL Server provider paths, these extended characters must be either encoded to their hexadecimal representation or escaped using the ` character. Certain characters, such as the colon character (:) cannot be escaped. The hexadecimal encoding for the characters is in the format %nn. The characters encoded by Encode-SqlName are: :./%*?[]|

Parameters
-SqlName <string>

  • This value is required
  • Accepts pipeline input ByValue

The SQL Server identifier to be encoded.

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

Inputs

String

Outputs

String

Examples
  1. Encodes a SQL Server table name that contains : and / characters:
    C:PS> Encode-SqlName -SqlName "My:Table/"
    
       My%3ATable%2F
Additional Notes
 
Related Links

Decode-SqlName