| Purpose: | Execute a PowerShell script or string |
or
| Execute TCC commands from Powershell |
| Format: | PSHELL [/C /S script ...] |
See also @PSHELL.
File Completion Syntax:
The default filename completion syntax is: [1] dirs ps1 [2*] *
Usage:
Note that you may need to enable PowerShell scripting on your system; on recent versions of Windows it is disabled by default (for security).
PSHELL supports multiple string or filename arguments. If a string or filename has embedded whitespace, you must enclose it with double quotes. For example:
pshell /s "type $Profile"
Without the double quotes PSHELL would interpret this as two commands.
PSHELL supports executing scripts in an NTFS stream (script:streamname).
TakeCommand.PowerShellHost
`[TakeCommand.PowerShellHost]` is available inside the in-process PowerShell session created by Take Command.
It exposes two static methods:
InvokeCommand(string command)
•Runs a TCC command line through `takecmd.dll`
•Returns the command output as a string
•Throws if the command fails or the host bridge is not initialized
ExpandValue(string expression)
•Expands a TCC variable or function expression through `takecmd.dll`
•Returns the expanded value as a string
•Throws if the expression fails or the host bridge is not initialized
Direct usage
powershell
$cwd = [TakeCommand.PowerShellHost]::ExpandValue('%_cwd')
"TCC current directory: $cwd"
$files = [TakeCommand.PowerShellHost]::InvokeCommand('dir /b')
"TCC dir /b output:"
$files
Helper commands added by the bridge
The PowerShell host also creates helper functions and aliases during session startup:
`Invoke-TccCommand` / `tcc`
`Expand-TccValue` / `tccx`
`Get-TccVariable` / `tccvar`
Execute a TCC command
powershell
tcc 'dir /b'
Expand a TCC expression
powershell
tccx '%@upper[test]'
Read a TCC variable
powershell
tccvar '_cwd'
tccvar '%_pid'
Notes
•These APIs are only available inside the embedded Take Command PowerShell host.
•`InvokeCommand()` returns captured command output. It does not return the numeric exit code.
•`ExpandValue()` is intended for TCC variable and function expansion such as `%_cwd` or `%@upper[test]`.
•Null or empty inputs are rejected.
Option: