Comparison of cmdlets with similar commands
The following table contains a selection of the cmdlets that ship with PowerShell noting the most similar commands in other well known command line interpreters.
Windows PowerShell (Cmdlet) | Windows PowerShell (Alias) | (MS-DOS, Windows, OS/2, etc.) | (Unix, BSD, Linux, Mac OS X etc.) | Description |
Get-Location | gl, pwd | Display the current directory/present working directory. | ||
Set-Location | sl, cd, chdir | cd | Change the current directory | |
Clear-Host | cls, clear | Clear the screen[35] | ||
Copy-Item | cpi, copy, cp | Copy one or several files / a whole directory tree | ||
Get-Help | help, man | Help on commands | ||
Remove-Item | ri, del, erase, rmdir, rd, rm | rm, rmdir | Delete a file / a directory | |
Rename-Item | rni, ren | Rename a file / a directory | ||
Move-Item | mi, move, mv | Move a file / a directory to a new location | ||
Get-ChildItem | gci, dir, ls | List all files / directories in the (current) directory | ||
Write-Output | echo, write | echo | Print strings, variables etc. to standard output | |
Pop-Location | popd | popd | Change the current directory to the directory most recently pushed onto the stack | |
Push-Location | pushd | pushd | Push the current directory onto the stack | |
Set-Variable | sv, set | set | Set the value of a variable / create a variable | |
Get-Content | gc, type, cat | Get the content of a file | ||
Select-String |
| Print lines matching a pattern | ||
Get-Process | gps, ps | List all currently running processes | ||
Stop-Process | spps, kill | kill | Stop a running process | |
Tee-Object | tee | n/a | Pipe input to a file or variable, then pass the input along the pipeline |
Examples
Examples are provided first using the long-form canonical syntax and then using more terse UNIX-like and DOS-like aliases that are set up in the default configuration.
- Stop all processes that begin with the letter "p":
PS> get-process p* | stop-process
PS> ps p* | kill
- Find the processes that use more than 1000 MB of memory and kill them:
PS> get-process | where-object { $_.WS -gt 1000MB } | stop-process
PS> ps | ? { $_.WS -gt 1000MB } | kill
- Calculate the number of bytes in the files in a directory:
PS> get-childitem | measure-object -property length -sum
PS> ls | measure length -s
PS> dir | measure length -s
- Determine whether a specific process is no longer running:
PS> $processToWatch = get-process notepad
PS> $processToWatch.WaitForExit()
PS> (ps notepad).WaitForExit()
- Change the case of a string from lower to upper:
PS> "hello, world!".ToUpper()
- Insert the string "ABC" after the first character in the word "string" to have the result "sABCtring":
PS> "string".Insert(1, "ABC")
- Download a specific RSS feed and show the titles of the 8 most recent entries:
PS> $rssUrl = "http://blogs.msdn.com/powershell/rss.aspx"
PS> $blog = [xml](new-object System.Net.WebClient).DownloadString($rssUrl)
PS> $blog.rss.channel.item | select title -first 8
$x=new-object xml;$x.load("http://blogs.msdn.com/powershell/rss.aspx");$x.rss.channel.item|select title -f 8
- Sets $UserProfile to the value of the UserProfile environment variable
PS> $UserProfile = $env:UserProfile
- Cast a .Net Namespace, and call a method exposed by the cast
PS> [System.Windows.Forms.MessageBox]::Show("Hello, World!")
- Run a command line executable, with arguments.
PS> [Array]$arguments = "-h", "15", "www.google.com"
PS> tracert $arguments
File extensions
- PS1 – Windows PowerShell shell script
- PS1XML – Windows PowerShell format and type definitions
- PSC1 – Windows PowerShell console file
- PSD1 – Windows PowerShell data file (for Version 2)
- PSM1 – Windows PowerShell module file (for Version 2)
Application support
SnapIns and hosts
Application | Version | Cmdlets | Provider | Management GUI |
2007 | 402 | Yes | Yes | |
Yes | Yes | No | ||
2008 | Yes | Yes | No | |
2007 | 74 | Yes | No | |
2007 | Yes | Yes | Yes | |
2007 | Yes | No | No | |
2007 | Yes | Yes | No | |
Microsoft Transporter Suite for Lotus Domino[38] | 08.02.0012 | 47 | No | No |
1.0 | 33 | No | No | |
6.0.2.2 | 44 | No | No | |
1.1 | 40 | No | No | |
Special Operations Software Specops Command[42] | 1.0 | Yes | No | Yes |
1.5 | 157 | No | No | |
7.0 | 54 | Yes | No | |
1.6 | Yes | No | Yes | |
6.1 | Yes | No | Yes | |
|
|
|
|
0 comments:
Post a Comment