This is a pocket guide to PowerShell for penetration testers. Advanced users will get nothing out of this.
Variables
Setting Variables:
$a=get-process
Retrieving values:
$a<enter>
Conditionals
Put conditionals inside {}
Symbol
PowerShell
<
-lt
>
-gt
<=
-le
>=
-ge
==
-eq
!=
-nq
Match String
-like
You can use ? to represent the output of the last command:
Loops
Print all elements in $a:
Execute a command returned by the loop use &:
Assign var $x to each elm:
General Tips
Create a list split by a delim
Get current powershell version:
Run older version of powershell:
Execution Policy
Execution policy is not a security protection. It is very easily bypassed. You can run PowerShell with the -noprofile to do so. You can also change the execution policy using: