Understanding cmdlet errors

When you work with cmdlets, you’ll encounter two standard types of errors:

Terminating errors. Errors that halt execution

Nonterminating errors. Errors that cause error output to be returned but do not halt execution

With both types of errors, you’ll typically see error text that can
help you resolve the problem that caused it. For example, an expected
file might be missing or you might not have sufficient permissions to
perform a specified task.

Using cmdlet aliases

For ease of use, Windows PowerShell lets you create aliases for
cmdlets. An alias is an abbreviation for a cmdlet that acts as a
shortcut for executing the cmdlet. For example, you can use the alias gsv instead of the cmdlet name Get-Service.

Table 3
provides a list of commonly used default aliases. Although there are
many other aliases, these are the ones you’ll use most frequently.

Table 3. Commonly used cmdlet aliases

ALIAS

CMDLET

clear, cls

Clear-Host

Diff

Compare-Object

cp, copy

Copy-Item

Epal

Export-Alias

Epcsv

Export-Csv

Foreach

ForEach-Object

Fl

Format-List

Ft

Format-Table

Fw

Format-Wide

Gal

Get-Alias

ls, dir

Get-ChildItem

Gcm

Get-Command

cat, type

Get-Content

h, history

Get-History

gl, pwd

Get-Location

gps, ps

Get-Process

Gsv

Get-Service

Gv

Get-Variable

Group

Group-Object

Ipal

Import-Alias

Ipcsv

Import-Csv

R

Invoke-History

Ni

New-Item

Mount

New-PSDrive

Nv

New-Variable

rd, rm, rmdir, del, erase

Remove-Item

Rv

Remove-Variable

Sal

Set-Alias

sl, cd, chdir

Set-Location

sv, set

Set-Variable

Sort

Sort-Object

Sasv

Start-Service

Sleep

Start-Sleep

spps, kill

Stop-Process

Spsv

Stop-Service

write, echo

Write-Output

You can define additional aliases using the Set-Alias cmdlet. The syntax is:

set-alias aliasName cmdletName

where aliasName is the alias you want to use and cmdletName is the cmdlet for which you are creating an alias. The following example creates a “go” alias for the Get-Process cmdlet:

set-alias go get-process

To use your custom aliases whenever you work with Windows PowerShell, enter the related command line in your profile.