Skip to content

Files

Latest commit

 

History

History
29 lines (17 loc) · 735 Bytes

AvoidUsingInvokeExpression.md

File metadata and controls

29 lines (17 loc) · 735 Bytes

Pattern: Use of Invoke-Expression

Issue: -

Description

Care must be taken when using the Invoke-Expression command. The Invoke-Expression executes the specified string and returns the results.

Code injection into your application or script can occur if the expression passed as a string includes any data provided from the user.

How

Remove the use of Invoke-Expression.

Example of incorrect code:

Invoke-Expression "Get-Process"

Example of correct code:

Get-Process

Further Reading