Documentation
¶
Overview ¶
Package powershell provides helpers for powershell command generation
Index ¶
Constants ¶
const PipeHasEnded = "The pipe has been ended."
PipeHasEnded string is used during the base64+sha265 upload process.
const PipeIsBeingClosed = "The pipe is being closed."
PipeIsBeingClosed string is used during the base64+sha265 upload process.
Variables ¶
This section is empty.
Functions ¶
func Cmd ¶
Cmd builds a command-line for executing a PowerShell command or script. Scripts that contain newlines, double-quotes, or cmd.exe metacharacters are passed via -EncodedCommand to avoid shell expansion; simple one-liners are passed via -Command so they remain readable in logs. cmd.exe metacharacters guarded: " % ! ^ & | < >.
func CompressedCmd ¶
CompressedCmd creates a scriptlet that will decompress and execute a gzipped script to both avoid command line length limits and to reduce data transferred.
func DoubleQuote ¶
DoubleQuote adds double quotes around a string and escapes any double quotes inside.
func DoubleQuotePath ¶
DoubleQuotePath adds double quotes around a string and escapes any double quotes inside. It also converts forward slashes to backslashes.
func EncodeCmd ¶
EncodeCmd base64-encodes a string as UTF-16LE in a way that is accepted by PowerShell -EncodedCommand.
func SingleQuote ¶
SingleQuote quotes and escapes a string in a format that is accepted by powershell scriptlets from jbrekelmans/go-winrm/util.go PowerShellSingleQuotedStringLiteral.
func SingleQuotePath ¶
SingleQuotePath single-quotes a path and converts forward slashes to backslashes. Use this instead of DoubleQuotePath when the value is passed to a -LiteralPath parameter or any context where PowerShell variable interpolation (e.g. '$' in directory names like C:\$Recycle.Bin) must not occur.
func ToWindowsPath ¶
ToWindowsPath converts a unix-style forward slash separated path to a windows-style path.
Types ¶
This section is empty.