Powershell - Invoke-Expression Cmdlet



Cmdlet

Invoke-Expression cmdlet is used to perform a command or expression on local computer.

In these example, we're see the Invoke-Expression cmdlet in action.

Example

In this example, we'll show how to invoke an expression.

> $Command = 'Get-Process'
 
> $Command
Get-Process
 
> Invoke-Expression $Command 

Output

Here you can notice that $Command print the expression where as Invoke-Expression executes the expression.

Handles  NPM(K)    PM(K)     WS(K)    VM(M)   CPU(s)       Id   ProcessName 
-------  ------    -----     -----    -----   ------     ----   ----------- 
     78       8     1288      3892       43     0.02     2556        armsvc 
    119       9    15808     15572       50               600       audiodg 
     88       8     2512      5860       73     0.02     3144        chrome  
    186      19    23360     31580      740     0.23     3148        chrome 
    218      22    28432     44848      769     0.86     3492        chrome 
powershell_advanced_cmdlets.htm
Advertisements