PowerShell

List all files with a particular extension in the current directory and its children, with results sorted by full file name.

Get-ChildItem -Path .\ -Filter *.sln -Recurse -File | Select Fullname | Sort-Object Fullname

List the 10 largest files in the current directory and subdirectories.

gci -r | sort Length -desc | select @{n="Length";e={$_.length}}, fullname -f 10

Search Files.ps1

Get-ChildItem -Recurse -Include *.item | select-string "<term>"
gci -r -i *.item | select-string "<term>"
gci -r -i *.* -exclude *.dll,*.xml | select-string "<term>"

Search with Git Grep.ps1

# Can only be run within a Git repository, but this will also search untracked files, as well as those that are tracked.
git grep --untracked '<term>'

View a file's contents

Get-Content .\path\to\file.ext

Environment variables

Get all environment variables.

dir Env:

Get environment variables at a certain scope.

[System.Environment]::GetEnvironmentVariables('User')
[System.Environment]::GetEnvironmentVariables('Machine')

Get a particular environment variable.

[Environment]::GetEnvironmentVariable("NAME_OF_VARIABLE")
[Environment]::GetEnvironmentVariable("NAME_OF_VARIABLE", "Machine")
[Environment]::GetEnvironmentVariable("NAME_OF_VARIABLE", "User")

Set an environment variable

$Env:NAME_OF_VARIABLE = "value"

Remove an environment variable

Remove-Item Env:\NAME_OF_VARIABLE