PowerShell Cheat Sheet v1.0 Importing, Exporting, & Converting
PowerShell Cheat Sheet v1.0
By: Fernando Tomlinson
@Wired_Pulse
Basics
Variables
Cmdlets
Commands built into the shell written in
.NET
Functions
Commands written in PowerShell
Parameter
Arguments to a cmdlet/function/script
Alias
Shortcut for a cmdlet or function
Scripts
Text files with .ps1 extension
Pipelines
Sends objects from one command to the
next
Assigns variable (string)
Convert-ToCliXML
Convert-ToHTML
[int]$var = 7
Assigns variable as int
Convert-ToCSV
Convert-FromCSV
$a = $b = $c = 11
Assigns each variable
with 11
Export-CSV
Import-CSV
Export-CliXML
Import-CliXML
Arrays and Objects
$array = 1, 2, 3, 4
Array of integers
$array = ¡°a¡±,¡±b¡±,¡±c¡±
Array of strings
$array = @()
Empty array
# Comment
Comment
?, Where
ForEach-Object
Where-Object
Cat, gc, type
Get-Content
Cd
Set-Location
Interrupt current command
Ctrl + left /
right
Navigate one word at a time
$array[3]
Fourth array element
Multiline comment
Home /End
Move to start / end of a line
$array[-5..-1]
Last three array elements
¡±`¡±Escape`¡±¡±
Escapes ` character
Move up and down through the history
(Get-Process).name
Name property of object
`n
New line
`r
Carriage return
`t
Horizontal tab
`v
Vertical tab
`
Line continue
Up /down
Help
Assignment, Logical, & Comparison Operators
=, +=, -=, ++, --
Assign to a variable
+=, -=
Appends to variable
++, --
Variable iteration
-and, -or, -not, !
Get-Help
Gets helps for
cmdlet
Help -examples
Gets examples for
cmdlet
Connect expressions /
statements
Get-Command ¨Cmodule
ABC
Lists all commands
in the ABC module
Clear, cls
Clear-Host
Compare, diff
Compare-Object
-eq, -ne
Equal, Not Equal
Get-Command
Copy, cp
Copy-Item
-gt, -ge
Curl, iwr, wget
Invoke-Webrequest
Greater than, greater than
or equal
Get a list of all
commands
Get-Command Get-*
Dir
Get-ChildItem
Less than, less than or
equal
Lists all commands
starting with ¡°get-¡±
Get-Service | Get-Member
Get-members of the
object
Get-Service | Format-List *
List of all properties
Echo
Erase, rm, del
Fl
Format-List
Ft
Format-Table
Gcm
Get-Command
Gm
Get-Member
Gwmi
Get-WMIObject
H, history
Get-History
Icm
Iex
Kill
Move, mv
Ogv
-lt, -le
Write-Output
Remove-Item
Invoke-Command
-replace
Replace one for one
-match, -notmatch
Regular expression match
-like, -notlike
Wildcard matching
-contains, -notcontains
Check if value in array
-in, -notin
Reverse of contains,
notcontains
Parameters
-Confirm
Prompt user to take action
-Whatif
Displays what the command would do
Invoke-Expression
Stop-Process
Comments & Escape Characters
Ctrl + C
Common Aliases
%, ForEach
Importing, Exporting, & Converting
$var = ¡°string¡±
While(){}
Do{} while()
ForEach($thing in $things){}
For($i=0; $i ¨Cgt 0; $i--){}
1..10 | ForEach{$_}
Scripts
Set-ExecutionPolicy ¨C
ExecutionPolicy
Unrestricted
Allows scripts to run
.\script.ps1
C:\script.ps1
$profile
Add-Content
Runs script
Get-Content
Set-Content
Runs script
Out-File
Out-String
Your personal profile
that runs at launch
Copy-Item
Remove-Item
Move-Item
Set-Item
New-Item
Get-Date
Get-Eventlog
Get-WinEvent
Writing output and reading data
¡°Hello, I am a string¡±
String written directly to output
Cmdlets
Set-Location
Move-Item
Out-GridView
Flow Control
If(){} ElseIf(){} Else{}
Pwd
Get-Location
Start-Sleep
Compare-Object
Ren, rni
Rename-Item
Write-Host ¡°some text¡± ¨Cforegroundcolor Blue
Displays text as blue
Test-Connection
Test-Path
Select
Select-Object
$day = Read-Host ¡°Enter day¡±
Sets $day variable to input from user
Get-ADUser
Get-SMBShare
Sort
Sort-Object
Get-Process | Out-GridView
Displays processes in an Excel-like output
Get-WMIObject
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- powershell 2 0 one cmdlet at a time
- powershell pipe
- import excel — import and export excel ï¬les
- powershell for projectwise how does it work
- powershell cheat sheet import export convert
- pnp powershell admin scripts export list data
- powershell cheat sheet v1 0 importing exporting converting
- index
- powershell basic cheat sheet rambling cookie monster
- pnp powershell admin scripts get user details from
Related searches
- cheat sheet for word brain game
- macro cheat sheet pdf
- logarithm cheat sheet pdf
- excel formula cheat sheet pdf
- excel formulas cheat sheet pdf
- excel cheat sheet 2016 pdf
- vba programming cheat sheet pdf
- macro cheat sheet food
- free excel cheat sheet download
- onenote cheat sheet pdf
- punctuation rules cheat sheet pdf
- excel formula cheat sheet printable