# powershell

# version info

[environment]::OSVersion.Version

$PSVersionTable

# three commands

Get-Command *process*   # the wild cards around process will find ANY command that contains the word process

Get-Help Stop-Process -Examples #  provides information about what a cmdlet does, and how it can be used

Get-Date | Get-Member   # Get-Member helps you identify what properties and methods are available to an object

See here (opens new window) for more details.

Get-Content .\doc.txt | Select-String -Pattern (Get-Content .\regex.txt)

# env vars

gci env:* | sort-object name    # print all env vars
env:$PATH
[Environment]::SetEnvironmentVariable("GIT_TRACE", 1, "Machine")

# modules

Get-Module -ListAvailable   # Gets all installed modules

# services

Get-WmiObject win32_service | Select Name, DisplayName, State, StartMode | Sort State, Name
start-service serviceName

# misc

. $profile

Get-ChildItem -Recurse | Unblock-File   # recursively unblock files

[guid]::NewGuid()

# command line

net user administrator | findstr /B /C:"Last logon" # get user last logon time