Powershell 3.0 Ise Cheat Sheet Page 3

ADVERTISEMENT

Windows PowerShell 3.0 Language Quick Reference
Created by
$Host
Reference to the application hosting the
$OFS
Output Field Separator. Specifies
Get-Command -Noun Variable # the Variable Cmdlets
POWERSHELL language
the character that separates the
Get-ChildItem variable: # listing all variables using the
$Input
Enumerator of objects piped to a script
elements of an array when the
variable drive
$LastExitCode
Exit code of last program or script
array is converted to a string. The
$Matches
Exit code of last program or script
default value is: Space.
# strongly-typed variable (can contain only integers)
$MyInvocation
An object with information about the
$OutputEncoding
Determines the character
[int]$number=8
current command
encoding method that Windows
$PSHome
The installation location of Windows
PowerShell uses when it sends
# attributes can be used on variables
PowerShell
text to other applications
[ValidateRange(1,10)][int]$number = 1
$profile
The standard profile (may not be
$PSDefaultParameterValues Specifies default values for the
$number = 11 #returns an error
present)
parameters of cmdlets and
$Switch
Enumerator in a switch statement
advanced functions
# flip variables
$True
Boolean value for TRUE
$PSEmailServer
Specifies the default e-mail server
$a=1;$b=2
$False
Boolean value for FALSE
that is used to send e-mail
$a,$b = $b,$a
$PSCulture
Current culture
messages
$PSUICulture
Current UI culture
$PSModuleAutoLoadingPreference Enables and disables
# multi assignment
$PsVersionTable Details about the version of Windows
automatic importing of modules
$a,$b,$c = 0
PowerShell
in the session. "All" is the default.
$a,$b,$c = 'a','b','c'
$Pwd
The full path of the current directory
$PSSessionApplicationName Specifies the default application
$a,$b,$c = 'a b c'.split()
name for a remote command that
uses WS-Management technology
# create read only variable (can be overwritten with -
Windows PowerShell Preference Variables
$PSSessionConfigurationName Specifies the default session
Force)
$ConfirmPreference
Determines whether Windows
Set-Variable -Name ReadOnlyVar -Value 3 -Option
configuration that is used for
PowerShell automatically
PSSessions created in the current
ReadOnly
prompts you for confirmation
session
before running a cmdlet or
# create Constant variable (cannot be overwritten)
$PSSessionOption
Establishes the default values for
function
advanced user options in a
Set-Variable -Name Pi -Value 3.14 -Option Constant
$DebugPreference
Determines how Windows
remote session
Windows PowerShell Automatic Variables
PowerShell responds to
$VerbosePreference
Determines how Windows
(not exhaustive)
debugging
PowerShell responds to verbose
$$
Last token of the previous
$ErrorActionPreference
Determines how Windows
messages generated by a script,
command line
PowerShell responds to a non-
cmdlet or provider
$?
Boolean status of last command
terminating error
$WarningPreference
Determines how Windows
$^
First token of the previous
$ErrorView
Determines the display format
PowerShell responds to warning
command line
of error messages in Windows
messages generated by a script,
$_, $PSItem
Current pipeline object
PowerShell
cmdlet or provider
$Args
Arguments to a script or function
$FormatEnumerationLimitDetermines how many
$WhatIfPreference
Determines whether WhatIf is
$Error
Array of errors from previous
enumerated items are included
automatically enabled for every
commands
in a display
command that supports it
$ForEach
Reference to the enumerator in a
$MaximumHistoryCount Determines how many
foreach loop
commands are saved in the
$Home
The user’s home directory
command history for the
current session

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 4