CodeGeneration Class

Definition

Contains utility methods for use in applications that generate PowerShell code.

C++
public ref class CodeGeneration abstract sealed
Inheritance
CodeGeneration

Methods

EscapeBlockCommentContent(String)

Escapes content so that it is safe for inclusion in a block comment. For example: "<#" + EscapeBlockCommentContent(userContent) + "#>"

EscapeFormatStringContent(String)

Escapes content so that it is safe for inclusion in a string that will later be used as a format string. If this is to be embedded inside of a single-quoted string, be sure to also call EscapeSingleQuotedStringContent. For example: "'" + EscapeSingleQuotedStringContent(EscapeFormatStringContent(userContent)) + "'" -f $args.

EscapeSingleQuotedStringContent(String)

Escapes content so that it is safe for inclusion in a single-quoted string. For example: "'" + EscapeSingleQuotedStringContent(userContent) + "'"

EscapeVariableName(String)

Escapes content so that it is safe for inclusion in a string that will later be used in a variable name reference. This is only valid when used within PowerShell's curly brace naming syntax.

For example: '${' + EscapeVariableName('value') + '}'

Applies to

Producto Versiones
PowerShell SDK 7.2.0, 7.3.0, 7.4.0
Windows PowerShell 5.1.0.0