PowerShell
![]() | |
![]() Screenshot of a PowerShell Core session in Windows Terminal | |
Paradigm | Imperative, pipeline, object-oriented, functional and reflective |
---|---|
Designed by | Jeffrey Snover, Bruce Payette, James Truher (et al.) |
Developer | Microsoft |
First appeared | November 14, 2006 |
Stable release | 7.2.0
/ November 9, 2021[2] |
Preview release | v7.2.0-rc.1[1]
/ October 23, 2021 |
Typing discipline | Strong, safe, implicit and dynamic |
Implementation language | C# |
Platform | .NET Framework, .NET Core |
OS |
|
License | MIT License[3] (but the Windows component remains proprietary) |
Filename extensions |
|
Influenced by | |
Python, Ksh, Perl, C#, CL, DCL, SQL, Tcl, Tk,[4] Chef, Puppet |
PowerShell 또는 Microsoft PowerShell (이전의 Windows PowerShell)은 명령-줄 쉘과 결합된 스크립팅 언어로 구성된 마이크로소프트의 임무 자동화와 구성 관리 프로그램입니다. 처음에는 Windows PowerShell로 알려진 윈도우 구성 요소 전용이었지만, 그것은 PowerShell Core의 도입으로 2016년 8월 18일에 오픈-소스 및 크로스-플랫폼이 되었습니다.[5] 전자는 .NET Framework에 구축되고, 후자는 .NET Core에 구축됩니다. Windows PowerShell이라는 이름은 여전히 최신 버전의 윈도우 11과 10에 존재하지만, 최신 버전의 PowerShell은 PowerShell 또는 Microsoft PowerShell이라고 불립니다.
PowerShell에서, 관리 임무는 일반적으로 특정 연산을 구현하는 특수 .NET 클래스를 전무화되는 cmdlets (command-lets으로 발음)에 의해 수행됩니다. 이것들은 providers를 통해 PowerShell에서 사용할 수 있게 만드는 파일 시스템 또는 레지스트리와 같은 다른 데이터 저장소에서 데이터에 접근함으로써 작동합니다. 타사 개발자는 PowerShell에 cmdlet와 providersf를 추가할 수 있습니다.[6][7] Cmdlet은 스크립트에 의해 사용될 수 있게 되며, 그것은 차례로 모듈로 패키지될 수 있습니다.
PowerShell은 COM 및 WMI에 대한 접근을 제공하여, 관리자에게 로컬 및 원격 윈도우 시스템뿐만 아니라 원격 리눅스 시스템 및 네트워크 장치의 관리를 가능하게 하고 마찬가지로 WS-Management 및 CIM에서 관리 작업을 수행할 수 있도록 합니다. PowerShell은 역시 PowerShell 런타임이 다른 응용 프로그램 내부에 삽입될 수 있는 호스팅 API를 제공합니다. 이들 응용 프로그램은 그런-다음 PowerShell 기능을 그래픽 인터페이스를 통해 노출되는 연산을 포함하여 특정 연산을 구현하기 위해 사용할 수 있습니다. 이 가능성은 Microsoft Exchange Server 2007에 의해 관리 기능을 PowerShell cmdlet와 providers로 표시하고 그래픽 관리 도구를 필요한 cmdlet을 호출하는 PowerShell 호스트로 구현하기 위해 사용되었습니다.[6][8] Microsoft SQL Server 2008을 포함한 다른 마이크로소프트 응용 프로그램도 PowerShell cmdlet을 통해 관리 인터페이스를 노출합니다. [9]
PowerShell은 Get-Help
cmdlet을 통해 접근할 수 있는 자체적인 광범위한 콘솔-기반 도움말 (유닉스 쉘의 매뉴얼 페이지와 유사)을 포함하고 있습니다. 업데이트된 로컬 도움말 내용은 Update-Help
cmdlet을 통해 인터넷에서 검색될 수 있습니다. 대안적으로, 웹에서 도움말은 -online
스위치를 Get-Help
로 전환하여 사례별로 획득될 수 있습니다.
Comparison of cmdlets with similar commands
윈도우 10에서, 파워셸은 Windows Powershell 아래에 Windows Powershell의 명령으로 제공됩니다. 이전에 사용하던 명령 프롬프트는 Windows 시스템아래에 명령어가 존재합니다.
아래 표에서, 2열은 파워셸에서 사용하는 명령어입니다. 물론 1열에 있는 긴 명령어를 사용할 수도 있지만, 너무 길어서 짧게 별칭으로 만든 것, 2열을 이용합니다. 3열은 명령 프롬프트이고 4열은 리눅스(Unik-like) 등에서 사용하는 명령어입니다.
파워셸과 명령 프롬프트, 그리고 리눅스 셸의 경로에 대한 차이점이 있습니다. 어떤 명령어를 실행하는 방법은 절대 경로로 실행하는 방법과 상대 경로로 실행하는 방법이 있습니다.
절대 경로는 최상위 디렉토리부터 현재 명령어까지 전체를 입력하는 방법입니다. 상대 경로는 현재 프롬프트 위치에서 명령어까지 찾아가는 경로입니다.
예를 들어, 프롬프트가 어떤 위치에 있더라도 c:\Temp\adb\adb.exe devices와 같이 실행하는 것이 절대 경로를 이용하는 방법입니다. 일반적으로 상대 경로를 주로 이용하는데, 이 경우에도 명령어가 있는 디렉토리, 예를 들어 c:\Temp\adb로 이동한 후에, 즉 현재 디렉토리에서, 명령 adb devices와 입력하는 방식입니다.
한편, 상대 경로에서 파워셸과 명령 프롬프트 사이에 차이가 생깁니다. 파워셸은 .\adb devices와 같이 현재 디렉토리를 나타내는 .\
를 반드시 입력해야 명령어가 실행됩니다. 반면에 명령 프롬프트는 현재 디렉토리를 나타내는 경로를 입력해도 되고, 입력하지 않아도 명령어가 실행됩니다. 참고로 리눅스에서는 ./
가 현재 디렉토리를 나타내고, 상대 경로에서 반드시 입력을 해야 실행됩니다.
파워셸과 명령 프롬프트의 공통점은 확장자를 입력해도 되고 안해도 된다는 점입니다. 즉, 경로를 제외하고 명령어 adb
와 adb.exe
는 같은 효력을 나타냅니다.
또한, 파워셸과 명령 프롬프트에서는 대소문자를 구별하지 않습니다. 절대 경로 경우의 예제에서 처럼, C:\tEMp\AdB\aDB.Exe devices와 같이 다소 이상한 일력에도 정상적인 반응을 합니다. 그러나, 마지막의 명령어 인수는 대소문자를 구별합니다. 명령어 인수는 adb.exe에서 정의하고, 윈도우 운영체제나 윈도우 내부 명령어와는 상관없이 별도로 정의됩니다. 반면에 리눅스는 대소문자를 항상 구별합니다.
PowerShell (Cmdlet) | PowerShell (Alias) | Windows Command Prompt | Unix shell | Description |
---|---|---|---|---|
Get-ChildItem | gci, dir, ls | dir | ls | Lists all files and folders in the current or given folder |
Test-Connection[a] | ping | ping | ping | Sends ICMP echo requests to the specified machine from the current machine, or instructs another machine to do so |
Get-Content | gc, type, cat | type | cat | Gets the content of a file |
Get-Command | gcm | help | type, which, compgen | Lists available commands |
Get-Help | help, man | help | apropos, man | Prints a command's documentation on the console |
Clear-Host | cls, clear | cls | clear | Clears the screen[b] |
Copy-Item | cpi, copy, cp | copy, xcopy, robocopy | cp | Copies files and folders to another location |
Move-Item | mi, move, mv | move | mv | Moves files and folders to a new location |
Remove-Item | ri, del, erase, rmdir, rd, rm | del, erase, rmdir, rd | rm, rmdir | Deletes files or folders |
Rename-Item | rni, ren, mv | ren, rename | mv | Renames a single file, folder, hard link or symbolic link |
Get-Location | gl, cd, pwd | cd | pwd | Displays the working path (current folder) |
Pop-Location | popd | popd | popd | Changes the working path to the location most recently pushed onto the stack |
Push-Location | pushd | pushd | pushd | Stores the working path onto the stack |
Set-Location | sl, cd, chdir | cd, chdir | cd | Changes the working path |
Tee-Object | tee | N/A | tee | Pipes input to a file or variable, passing the input along the pipeline |
Write-Output | echo, write | echo | echo | Prints strings or other objects to the standard output |
Get-Process | gps, ps | tlist,[c] tasklist[d] | ps | Lists all running processes |
Stop-Process | spps, kill | kill,[c] taskkill[d] | kill[e] | Stops a running process |
Select-String | sls | findstr | find, grep | Prints lines matching a pattern |
Set-Variable | sv, set | set | env, export, set, setenv | Creates or alters the contents of an environment variable |
Invoke-WebRequest | iwr, |
N/A | wget, curl | Gets contents from a web page on the Internet |
Notes
- ^ While the external ping command remains available to PowerShell, Test-Connection's output is a structured object that can be programmatically inspected.[10]
- ^ Clear-Host is implemented as a predefined PowerShell function.
- ^ a b Available in Windows NT4, Windows 98 Resource Kit, Windows 2000 Support Tools
- ^ a b Available in Windows XP Professional Edition and later
- ^ Also used in UNIX to send a process any signal, the "Terminate" signal is merely the default
- ^
curl
andwget
are absent from PowerShell Core, so as to not interfere with invoking similarly named components of non-Windows OSes.
See also
- Common Information Model
- Comparison of command shells
- Comparison of programming languages
- Web-Based Enterprise Management
- Windows Script Host
References
- ^ "PowerShell 7.2.0 RC1 now available for testing - MSPoweruser".
- ^ "PowerShell/PowerShell". GitHub. Retrieved 2021-11-09.
- ^ "PowerShell for every system!". 12 June 2017 – via GitHub.
- ^ Snover, Jeffrey (May 25, 2008). "PowerShell and WPF: WTF". Windows PowerShell Blog. Microsoft.
- ^ Bright, Peter (2016-08-18). "PowerShell is Microsoft's latest open source release, coming to Linux, OS X". Ars Technica. Condé Nast. Archived from the original on 2020-04-09. Retrieved 2020-05-12.
- ^ a b "How Windows PowerShell works". Microsoft Developer Network. Microsoft. Retrieved 2007-11-27.
- ^ Truher, Jim (December 2007). "Extend Windows PowerShell With Custom Commands". MSDN Magazine. Microsoft. Archived from the original on 6 October 2008.
- ^ Lowe, Scott (January 4, 2007). "Exchange 2007: Get used to the command line". TechRepublic. CBS Interactive. Archived from the original on 2018-11-16. Retrieved 2020-05-12.
- ^ Snover, Jeffrey (2007-11-13). "SQL Server Support for PowerShell!". Windows PowerShell Blog (blog posting). Microsoft. Archived from the original on 2007-11-15. Retrieved 2007-11-13.
- ^ "Test-Connection". PowerShell documentations. Microsoft. 9 August 2015.
Further reading
- Oakley, Andy (2005). Monad (AKA PowerShell). O'Reilly Media. ISBN 0-596-10009-4.
- Holmes, Lee (2006). Windows PowerShell Quick Reference. O'Reilly Media. ISBN 0-596-52813-2.
- Holmes, Lee (2007). Windows PowerShell Cookbook. O'Reilly Media. ISBN 0-596-52849-3.
- Watt, Andrew (2007). Professional Windows PowerShell. Wrox Press. ISBN 0-471-94693-1.
- Kumaravel, Arul; White, Jon; Naixin Li, Michael; Happell, Scott; Xie, Guohui; Vutukuri, Krishna C. (2008). Professional Windows PowerShell Programming: Snapins, Cmdlets, Hosts and Providers. Wrox Press. ISBN 0-470-17393-9.
- Kopczynski, Tyson; Handley, Pete; Shaw, Marco (2009). Windows PowerShell Unleashed (2nd ed.). Pearson Education. ISBN 978-0-672-32988-3.
- Jones, Don; Hicks, Jeffery (2010). Windows PowerShell 2.0: TFM (3rd ed.). Sapien Technologies. ISBN 978-0-9821314-2-8.
- Finke, Douglas (2012). Windows PowerShell for Developers. O'Reilly Media. ISBN 1-4493-2270-0.
- Wilson, Ed (2013). Windows PowerShell 3.0 Step by Step. Microsoft Press. ISBN 978-0-7356-6339-8.
- Wilson, Ed (2014). Windows PowerShell Best Practices. Microsoft Press. ISBN 978-0-7356-6649-8.
External links