Use Get-Member to list all properties and methods of an object!
get-commandset*# Searches for all cmdlets that start with "set"alias# List all aliases in shellGet-ChildItem# Same as ls, dir, and gciCopy-Item# Same as cp, copy, and cpiMove-Item# Same as mv, move, and miSelect-String# Same as sls and similar to grepGet-Help# Get help!!Get-Content# Same as cat, type, gcGet-Process# Same as ps, gpsGet-Location# Same as pwd, glGet-Member# Get properties and methods of objects - USEFUL!!!!ps|format-list-propertyname,id,starttime# Formatted list of process propertieslsenv:# List all PS environment variableslsvariable:# List all PS variables
Getting Help
helpgci# displays help for Get-ChildItemhelpgci-detailed# Very verbose help informationhelpgci-examples# Examples on how to USE it!!!helpgci-full# Pretty much everything it has about itRemove-Item*.*-WhatIf# Explains what WOULD happen, but not actually do it
Pipeline Objects
Used to help automate between operations in a pipe. The % is an alias for ForEach-Object command. The current object in an array of objects is referred to as $_. Pipeline objects can be filtered with the ? alias for Where-Object. Command below will write out all names and PIDs of processes returned by ps alias.
ps|gm# Find all properties and methods firstps|%{write-host"name is" $_.name" and pid is " $_.ID}ps|?{write-host"Running PID name is " $_.status-eq"running"}# Counting loops to move between two sets of numbers1..10|%{echo $_}1..255|%{ping-n1192.168.0.$_ | select-string ttl}
Enumerate Local Users
Enumerate the local users on the machine and print out important information about their accounts.
We can import the signed Microsoft ActiveDirectory module into PowerShell directly in memory to enumerate AD users and systems. This leverages the signed module kept at https://github.com/samratashok/ADModule. After importing we have access to all AD commands in PowerShell.
# Search the entire C:\ dir for anything with "password" in the filename. Put stderr in null where it belongsgci-recurseC:\ password2>$null |%{echo $_.fullname}# Select-string works similar to grepselect-string -path C:\Users\*.txt -pattern password# Put both together! Look in each file for the string "password"gci-recurseC:\ |%{select-string-path $_ -patternpassword}2>$null
Navigate Registry
# Can navigate Reg just like the file system using tab completioncdHKLM:\