Skip to content
Search

Windows PowerShell

lastmod 2025-12-15created 2016-04-1514 edits

Windows PowerShell is an extensible command-line interface (CLI) shell and scripting language developed by Microsoft. It is designed on an object-oriented basis and is built on .NET Framework 2.0. It was previously called Microsoft Shell (MSH, codename Monad).

It currently supports Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2012, and Windows Server 2008 R2.

Categories

Commands

Characteristics of PowerShell commands

cmdlets take the form Verb-Noun.

  • Verbs include Get, New, Restart, Resume, Set, Start, Stop, Suspend, etc.,
  • and nouns include Computer, Service, Host, Alias, ChildItem, and so on.

Comments

# 한 줄 주석 처리

<#
 여러 줄 주석 처리
#>

Get-Command (gcm)

# 기본적으로 명령어의 대소문자는 구분하지 않습니다.
Get-Command # 모든 명령어(Cmdlet, function)들을 출력
gcm         # 똑같은 결과
gcm Get-*   # get- 로 시작하는 모든 명령을 출력
gcm -Module UEV # UEV 모듈 안에 있는 모든 명령 출력
gcm -Verb Get # '동사' 가 Get인 모든 명령 출력
gcm -Noun Computer # '명사' 가 컴퓨터인 모든 명령 출력
gcm Get-Help -Syntax # 'Get-Help' 의 모든 구문 출력 (여기서는 별칭 사용 하면 안됨)

Get-Help

Get-Help Get-ChildItem # 'Get-ChildItem' 명령에 대한 정보 출력
Get-ChildItem -?        # 같음
Get-Help Get-ChildItem -Detailed # 'Get-ChildItem' 명령에 대한 자세한 정보 출력
Get-Help Get-ChildItem -Full # 'Get-ChildItem' 명령에 대한 모든 정보 출력
Get-Help Get-ChildItem -Examples # 'Get-ChildItem' 명령에 대한 예시 출력
Get-Help Get-ChildItem -Online # 'Get-ChildItem' 명령에 대한 자세한 정보를 웹에서 확인

man and help show the same result, but the difference is that they print one page at a time

Get-Location (pwd)

Prints the path where PowerShell is currently located

Get-Location # 현재 Path를 출력
pwd 

Set-Location (cd)

Change the working directory

Set-Location -Path 'C:\' # -Path 는 생략 가능
cd 'C:\' # 'C:\' 로 위치 변경

Get-ChildItem (gci, ls, dir)

Get-ChildItem -Path C:\Test # -Path 는 생략 가능 
ls c:\Test -Name # 이름만 출력
ls C:\Test\*.txt -Recurse -Force # 'C:\Test' 의 서브 디렉토리에 있는 모든 .txt 파일 출력
ls C:\Test\Logs\* -Exclude A* # A로 시작하는 파일을 제외한 목록 출력

Count Files, Words, and Lines

Get-ChildItem -Path D:\Temp -Force | Measure-Object

Running a script downloaded from the web directly

Use iwr (Invoke-WebRequest). Similar to the curl example:

powershell -Command "iwr https://fly.io/install.ps1 -useb | iex"

Invoke-WebRequest

See Invoke-WebRequest.

Tools

See also

Favorite site

author Zer0 sitemap