Difference between revisions of "Windows PowerShell 1.0 Commands and Aliases"
(→PowerShell 1.0 Alias Summary) |
(→Creating New PowerShell Aliases) |
||
Line 287: | Line 287: | ||
</table> | </table> | ||
− | == Creating | + | == Creating and Listing PowerShell Aliases == |
New aliases may be created, or existing ones changed using the ''Set-Alias'' command. For example, to create an alias of ''list'' for the ''Get-ChildItem'' command (which provides listing of the contents of a directory) the following command would be executed: | New aliases may be created, or existing ones changed using the ''Set-Alias'' command. For example, to create an alias of ''list'' for the ''Get-ChildItem'' command (which provides listing of the contents of a directory) the following command would be executed: |
Revision as of 19:11, 12 November 2008
Windows PowerShell contains a wide range of built-in commands which which can be used either in the interactive shell environment, or within cmdlet scripts. In addition, each command also has a pre-configured alias which typically shortens the amount of typing necessary to invoke a command, and often provides access to a command via a more familiar name. For example, the Get-ChildItem command for listing the contents of a directory may also be executed using the more familiar dir alias.
In this chapter of Windows PowerShell 1.0 Essentials a summary of each command is provided, together with a table of alias to command relationships.
PowerShell 1.0 Command Summary
As previously mentioned, Windows PowerShell 1.0 is supplied with a wide range of built-in commands. A full listing of available commands may be displayed from with the interactive shell by typing help. For the command-line syntax of a particular command, use the Get-Command command passing the name of the command as an argument:
PS C:\Users\Administrator> get-command pop-location CommandType Name Definition ----------- ---- ---------- Cmdlet Pop-Location [-PassThru] [-StackName <String>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]...
The following table lists the different commands provided with Windows PowerShell 1.0:
Command |
Type |
Description |
---|---|---|
Get-Command | Cmdlet | Get basic information about cmdlets and other elements of Windows PowerShell commands. |
Get-Help | Cmdlet | Display information about Windows PowerShell cmdlets. |
Get-History | Cmdlet | Get a list of the previous commands entered during the current session. |
Invoke-History | Cmdlet | Run selected commands from the session history. |
Add-History | Cmdlet | Append entries to the session history. |
ForEach-Object | Cmdlet | Perform an operation against each of a set of input objects. |
Where-Object | Cmdlet | Create a filter that controls which objects will be passed along a command pipeline. |
Set-PSDebug | Cmdlet | Turns script debugging features on and off, sets the trace level and toggles strict mode. |
Add-PSSnapin | Cmdlet | Add one or more Windows PowerShell snap-ins to the current console. |
Remove-PSSnapin | Cmdlet | Remove Windows PowerShell snap-ins from the current console. |
Get-PSSnapin | Cmdlet | Get the Windows PowerShell snap-ins on the computer. |
Export-Console | Cmdlet | Export the configuration of the current console to a file so that you can reuse or share it. |
Start-Transcript | Cmdlet | Create a record of all or part of a Windows PowerShell session in a text file. |
Stop-Transcript | Cmdlet | Stop a transcript. |
Add-Content | Cmdlet | Add content to the specified item(s). |
Clear-Content | Cmdlet | Delete the contents of a item, such as deleting the text from a file, but does not delete the item. |
Clear-ItemProperty | Cmdlet | Delete the value of a property but it does not delete the property. |
Join-Path | Cmdlet | Combines a path and child-path into a single path. The provider supplies the path delimiters. |
Convert-Path | Cmdlet | Convert a path from a Windows PowerShell path to a Windows PowerShell provider path. |
Copy-ItemProperty | Cmdlet | Copy a property and value from a specified location to another location. |
Get-EventLog | Cmdlet | Get information about local event logs or the entries stored in those event logs. |
Get-ChildItem | Cmdlet | Get the items and child items in one or more specified locations. |
Get-Content | Cmdlet | Get the content of the item at the specified location. |
Get-ItemProperty | Cmdlet | Retrieve the properties of a specified item. |
Get-WmiObject | Cmdlet | Get instances of WMI classes or information about available classes. |
Move-ItemProperty | Cmdlet | Move a property from one location to another. |
Get-Location | Cmdlet | Get information about the current working location. |
Set-Location | Cmdlet | Set the current working location to a specified location. |
Push-Location | Cmdlet | Push the current location onto the stack. |
Pop-Location | Cmdlet | Changes the current location to the location most recently pushed onto the stack. You can pop the location from the default stack or from a stack that you create by using Push-Location. |
New-PSDrive | Cmdlet | Install a new Windows PowerShell drive. |
Remove-PSDrive | Cmdlet | Remove a Windows PowerShell drive from its location. |
Get-PSDrive | Cmdlet | Get information about Windows PowerShell drives. |
Get-Item | Cmdlet | Get the item at the specified location. |
New-Item | Cmdlet | Create a new item in a namespace. |
Set-Item | Cmdlet | Change the value of an item to the value specified in the command. |
Remove-Item | Cmdlet | Delete the specified items. |
Move-Item | Cmdlet | Move an item from one location to another. |
Rename-Item | Cmdlet | Rename an item in a Windows PowerShell provider namespace. |
Copy-Item | Cmdlet | Copy an item from one location to another within a namespace. |
Clear-Item | Cmdlet | Delete the contents of an item, but does not delete the item. |
Invoke-Item | Cmdlet | Invoke the provider-specific default action on the specified item. |
Get-PSProvider | Cmdlet | Get information about the specified Windows PowerShell provider. |
New-ItemProperty | Cmdlet | Set a new property of an item at a location. |
Split-Path | Cmdlet | Return the specified part of a path. |
Test-Path | Cmdlet | Determine whether all elements of a path exist. |
Get-Process | Cmdlet | Get the processes that are running on the local computer. |
Stop-Process | Cmdlet | Stop one or more running processes. |
Remove-ItemProperty | Cmdlet | Delete the property and its value from an item. |
Rename-ItemProperty | Cmdlet | Rename a property of an item. |
Resolve-Path | Cmdlet | Resolve the wildcard characters in a path and displays the path contents. |
Get-Service | Cmdlet | Get the services on the local computer. |
Stop-Service | Cmdlet | Stop one or more running services. |
Start-Service | Cmdlet | Start one or more stopped services. |
Suspend-Service | Cmdlet | Suspend (pauses) one or more running services. |
Resume-Service | Cmdlet | Resumes one or more suspended (paused) services. |
Restart-Service | Cmdlet | Stop and then start one or more services. |
Set-Service | Cmdlet | Change the display name, description, or starting mode of a service. |
New-Service | Cmdlet | Create a new entry for a Windows Service in the registry and the Service Database. |
Set-Content | Cmdlet | Write or replaces the content in an item with new content. |
Set-ItemProperty | Cmdlet | Set the value of a property at the specified location. |
Get-Acl | Cmdlet | Get the security descriptor for a resource, such as a file or registry key. |
Set-Acl | Cmdlet | Change the security descriptor of a specified resource, such as a file or a registry key. |
Get-PfxCertificate | Cmdlet | Get information about .pfx certificate files on the computer. |
Get-Credential | Cmdlet | Get a credential object based on a user name and password. |
Get-ExecutionPolicy | Cmdlet | Get the current execution policy for the shell. |
Set-ExecutionPolicy | Cmdlet | Change the user preference for the execution policy of the shell. |
Get-AuthenticodeSignature | Cmdlet | Get information about the Authenticode signature in a file. |
Set-AuthenticodeSignature | Cmdlet | Use an authenticode signature to sign a Windows PowerShell script or other file. |
ConvertFrom-SecureString | Cmdlet | Convert a secure string into an encrypted standard string. |
ConvertTo-SecureString | Cmdlet | Convert encrypted standard strings to secure strings. It can also convert plain text to secure strings. It is used with ConvertFrom-SecureString and Read-Host. |
Format-List | Cmdlet | Format the output as a list of properties in which each property appears on a new line. |
Format-Custom | Cmdlet | Use a customized view to format the output. |
Format-Table | Cmdlet | Format the output as a table. |
Format-Wide | Cmdlet | Format objects as a wide table that displays only one property of each object. |
Out-Null | Cmdlet | Delete output instead of sending it to the console. |
Out-Default | Cmdlet | Send the output to the default formatter and the default output cmdlet. Has no effect on the formatting or output and is provided as a placeholder that lets you write your own Out-Default function or cmdlet. |
Out-Host | Cmdlet | Send output to the command line. |
Out-File | Cmdlet | Send output to a file. |
Out-Printer | Cmdlet | Send output to a printer. |
Out-String | Cmdlet | Send objects to the host as a series of strings. |
Add-Member | Cmdlet | Add a user-defined custom member to an instance of a Windows PowerShell object. |
Compare-Object | Cmdlet | Compare two sets of objects. |
ConvertTo-Html | Cmdlet | Create an HTML page that represents an object or a set of objects. |
Export-Csv | Cmdlet | Create a comma-separated values (CSV) file that represents the input objects. |
Import-Csv | Cmdlet | Imports comma-separated value (CSV) files in the format produced by the Export-CSV cmdlet and returns objects that correspond to the objects represented in that CSV file. |
Export-Alias | Cmdlet | Export information about currently-defined aliases to a file. |
Invoke-Expression | Cmdlet | Run a Windows PowerShell expression that is provided in the form of a string. |
Get-Alias | Cmdlet | Get the aliases for the current session. |
Get-Culture | Cmdlet | Get information about the regional settings on a computer. |
Get-Date | Cmdlet | Get the current date and time. |
Get-Host | Cmdlet | Get a reference to the current console host object. Display Windows Powershell version and regional information by default. |
Get-Member | Cmdlet | Get information about objects or collections of objects. |
Get-UICulture | Cmdlet | Get information about the current user interface culture for Windows PowerShell. |
Get-Unique | Cmdlet | Return the unique items from a sorted list. |
Import-Alias | Cmdlet | Import an alias list from a file. |
Select-String | Cmdlet | Identify patterns in strings. |
Measure-Object | Cmdlet | Measure characteristics of objects and their properties. |
New-Alias | Cmdlet | Create a new alias. |
New-TimeSpan | Cmdlet | Create a TimeSpan object. |
Read-Host | Cmdlet | Read a line of input from the console. |
Set-Alias | Cmdlet | Create or changes an alias (alternate name) for a cmdlet or other command element in the current Windows PowerShell session. |
Set-Date | Cmdlet | Change the system time on the computer to a time that you specify. |
Start-Sleep | Cmdlet | Suspend shell, script, or runspace activity for the specified period of time. |
Tee-Object | Cmdlet | Pipe object input to a file or variable, then passes the input along the pipeline. |
Measure-Command | Cmdlet | Measure the time it takes to run script blocks and cmdlets. |
Update-TypeData | Cmdlet | Update the current extended type configuration by reloading the *.types.ps1xml files into memory. |
Update-FormatData | Cmdlet | Update and appends format data files. |
Write-Host | Cmdlet | Display objects by using the host user interface |
Write-Progress | Cmdlet | Display a progress bar within a Windows PowerShell command window. |
New-Object | Cmdlet | Create an instance of a .Net or COM object. |
Select-Object | Cmdlet | Selects specified properties of an object or set of objects. It can also select unique objects from an array of objects or it can select a specified number of objects from the beginning or end of an array of objects. |
Group-Object | Cmdlet | Groups objects that contain the same value for specified properties. |
Sort-Object | Cmdlet | Sorts objects by property values. |
Get-Variable | Cmdlet | Get the variables in the current console. |
New-Variable | Cmdlet | Create a new variable. |
Set-Variable | Cmdlet | Set the value of a variable. Create the variable if one with the requested name does not exist. |
Remove-Variable | Cmdlet | Delete a variable and its value. |
Clear-Variable | Cmdlet | Delete the value of a variable. |
Export-Clixml | Cmdlet | Create an XML-based representation of an object or objects and stores it in a file. |
Import-Clixml | Cmdlet | Import a CLIXML file and creates corresponding objects within Windows PowerShell. |
Write-Debug | Cmdlet | Write a debug message to the host display. |
Write-Verbose | Cmdlet | Write a string to the verbose display of the host. |
Write-Warning | Cmdlet | Write a warning message. |
Write-Error | Cmdlet | Write an object to the error pipeline. |
Write-Output | Cmdlet | Write objects to the success pipeline. |
Get-TraceSource | Cmdlet | Get the Windows PowerShell components that are instrumented for tracing. |
Set-TraceSource | Cmdlet | Configures, starts, and stops a trace of Windows PowerShell components. |
Trace-Command | Cmdlet | The Trace-Command cmdlet configures and starts a trace of the specified expression or command. |
Alias | Provider | Provides access to the Windows PowerShell aliases and the values that they represent. |
Environment | Provider | Provides access to the Windows environment variables. |
FileSystem | Provider | The PowerShell Provider for accessing files and directories from within the Windows PowerShell. |
Function | Provider | Provides access to the functions defined in Windows PowerShell. |
Registry | Provider | Provides access to the system registry keys and values from within Windows PowerShell. |
Variable | Provider | Provides access to the Windows PowerShell variables and their values. |
Certificate | Provider | Provides access to X509 certificate stores and certificates from within Windows PowerShell. |
PowerShell 1.0 Alias Summary
Each PowerShell command has a pre-configured alias which can be used to invoke the command. These are often greatly abbreviated to reduce the amount of typing required, and occasionally used to provide a more familiar name.
A full list of pre-defined PowerShell 1.0 aliases is provided in the following table:
Alias |
Command |
---|---|
ac | Add-Content |
asnp | Add-PSSnapin |
clc | Clear-Content |
cli | Clear-Item |
clp | Clear-ItemProperty |
clv | Clear-Variable |
cpi | Copy-Item |
cpp | Copy-ItemProperty |
cvpa | Convert-Path |
diff | Compare-Object |
epal | Export-Alias |
epcsv | Export-Csv |
fc | Format-Custom |
fl | Format-List |
foreach | ForEach-Object |
% | ForEach-Object |
ft | Format-Table |
fw | Format-Wide |
gal | Get-Alias |
gc | Get-Content |
gci | Get-ChildItem |
gcm | Get-Command |
gdr | Get-PSDrive |
ghy | Get-History |
gi | Get-Item |
gl | Get-Location |
gm | Get-Member |
gp | Get-ItemProperty |
gps | Get-Process |
group | Group-Object |
gsv | Get-Service |
gsnp | Get-PSSnapin |
gu | Get-Unique |
gv | Get-Variable |
gwmi | Get-WmiObject |
iex | Invoke-Expression |
ihy | Invoke-History |
ii | Invoke-Item |
ipal | Import-Alias |
ipcsv | Import-Csv |
mi | Move-Item |
mp | Move-ItemProperty |
nal | New-Alias |
ndr | New-PSDrive |
ni | New-Item |
nv | New-Variable |
oh | Out-Host |
rdr | Remove-PSDrive |
ri | Remove-Item |
rni | Rename-Item |
rnp | Rename-ItemProperty |
rp | Remove-ItemProperty |
rsnp | Remove-PSSnapin |
rv | Remove-Variable |
rvpa | Resolve-Path |
sal | Set-Alias |
sasv | Start-Service |
sc | Set-Content |
select | Select-Object |
si | Set-Item |
sl | Set-Location |
sleep | Start-Sleep |
sort | Sort-Object |
sp | Set-ItemProperty |
spps | Stop-Process |
spsv | Stop-Service |
sv | Set-Variable |
tee | Tee-Object |
where | Where-Object |
? | Where-Object |
write | Write-Output |
cat | Get-Content |
cd | Set-Location |
clear | Clear-Host |
cp | Copy-Item |
h | Get-History |
history | Get-History |
kill | Stop-Process |
lp | Out-Printer |
ls | Get-ChildItem |
mount | New-PSDrive |
mv | Move-Item |
popd | Pop-Location |
ps | Get-Process |
pushd | Push-Location |
pwd | Get-Location |
r | Invoke-History |
rm | Remove-Item |
rmdir | Remove-Item |
echo | Write-Output |
cls | Clear-Host |
chdir | Set-Location |
copy | Copy-Item |
del | Remove-Item |
dir | Get-ChildItem |
erase | Remove-Item |
move | Move-Item |
rd | Remove-Item |
ren | Rename-Item |
set | Set-Variable |
type | Get-Content |
Creating and Listing PowerShell Aliases
New aliases may be created, or existing ones changed using the Set-Alias command. For example, to create an alias of list for the Get-ChildItem command (which provides listing of the contents of a directory) the following command would be executed:
PS C:\Users\Administrator> set-alias list get-childitem
A list of currently defined aliases may be obtained using the Get-Alias command:
PS C:\Users\Administrator> get-alias
In addition, the current command to which an alias is mapped may be obtained by referencing the alias as an argument to Get-Alias:
PS C:\Users\Administrator> get-alias set CommandType Name Definition ----------- ---- ---------- Alias set Set-Variable