Skip to content

Instantly share code, notes, and snippets.

@Sporax
Created February 13, 2019 18:06
Show Gist options
  • Save Sporax/5233c0b711d3e39e2b7887e2dbd382b3 to your computer and use it in GitHub Desktop.
Save Sporax/5233c0b711d3e39e2b7887e2dbd382b3 to your computer and use it in GitHub Desktop.
WMIC cheat sheet

WMIC

computer name:

wmic computersystem get "Name"

processes:

wmic process

processor name:

wmic CPU get Name

math:

normal and [math]::fnname(args)

variable declaration:

$varname = value

list directory

get-childitem

list by date

get-childitem | sort-object date

find command containing substring:

proper way: gcm -name "substring" shady way: use wildcard (*) and autocomplete (tab)

save all file data and metadata to csv:

gci | export-csv filename.csv

registry from powershell

get-psdrive -psprovider registry

command on remote computer

Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME enter-pssession computername

add user

new-aduser -name [name] -surname [surname] -samaccountname [login] -AccountPassword * new-psdrive add-adgroupmember

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment