한국어 POWERSHELL 자주 묻는 질문

By | April 11, 2015

translated-korean


개념 : PowerShell에 대해 가장 많이 묻는 질문.

여러 가지 방법으로 이 목록을 사용하실 수 있습니다:

  • 스크립트에 명령 복사/붙여 넣기
  • 특정 명령의 구문을 신속하게 확인
  • 기술 지식 향상
  • 새 명령 습득
  • 면접 준비

업데이트
2015년 10월 7일
저자 powershell-guru.com
출처 korean.powershell-guru.com
카테고리
75
질문
610


ACL
Active Directory
Alias
Arrays
Browsers
Certificates
Characters
CIM
Comments
COM Objects
Compare
Computer
Credentials
CSV
Culture
Date
Drives
Environment
Errors
Event Viewer
Files
Folders
Format Operator (-f)
Functions
GPO
GUI
Hardware
Hashtables
Help
History
Jobs
Keyboard
Loops
Math
Memory
Messages
Modules
Microsoft Excel
Microsoft Exchange
Microsoft Outlook
Microsoft SharePoint
Networking
Openfiles
Operators
Parameters
Password
Powershell ISE
Powershell v5
Printers
Processes
PSObject
Quest
Random
RDP
Regedit
Regex
Remote
Restore
Scheduled Tasks
Search
SCCM
Services
SMTP
Snapins
Sounds
Static .NET Methods
Strings
System
Try/Catch
Variables
Symantec Vault
Windows 2012
Windows Azure
Windows Forms
WMI
XML

System

PowerShell의 나의 버전을 어떻게 확인하나요?

이전 버전과의 호환성을 위해 다른 버전에서 PowerShell을 어떻게 실행하나요?
powershell.exe -Version 2.0

PowerShell로 스크립트에서 최소 PowerShell 버전 (3.0 이상)을 어떻게 필요로하나요?
#Requires -Version 3.0

PowerShell로 스크립트에 대한 관리 권한을 어떻게 필요로하나요?

PowerShell로 스크립트의 매개 변수를 어떻게 확인하나요?
help -Name .\Get-ExchangeEnvironmentReport.ps1 -Full

PowerShell로 현 사용자에 대한 정보를 어떻게 얻나요?
[Security.Principal.WindowsIdentity]::GetCurrent()

PowerShell로 프로필을 어떻게 생성, 수정 및 재로드하나요?

PowerShell로 스크립트에서 5 초 / 분 일시 중지를 어떻게 하나요?
Start-Sleep -Seconds 5
Start-Sleep -Seconds 300 # 5 minutes

PowerShell로 마지막 부팅 시간을 어떻게 얻나요?
(Get-CimInstance -ClassName win32_operatingsystem).LastBootUpTime

PowerShell로 액셀레이터 타입을 어떻게 얻나요?

PowerShell로 시작 프로그램을 어떻게 나열하나요?

PowerShell로 애플리케이션을 어떻게 제거하나요?

PowerShell로 전체 데스크탑 또는 활성화 윈도우의 스크린샷을 어떻게 촬영하나요?
Take-ScreenShot -Screen -File 'C:\scripts\screenshot.png' -Imagetype JPEG
Repository : Take-ScreenShot

PowerShell로 MSMQ 대기열의 메시지 수를 어떻게 얻나요?

PowerShell로 실행 정책을 어떻게 설정하나요?

PowerShell로 바로 가기를 어떻게 만드나요?

PowerShell로 작업 표시 줄에 프로그램을 어떻게 고정 또는 고정 해제하나요?

PowerShell로 탐색기 창을 어떻게 여나요?
[Diagnostics.Process]::Start('explorer.exe')
Invoke-Item -Path C:\Windows\explorer.exe

PowerShell로 장치 드라이버를 어떻게 나열하나요?
Get-WmiObject -Class Win32_PnPSignedDriver
Get-WindowsDriver -Online -All
driverquery.exe

PowerShell로 GUID를 어떻게 생성하나요?

PowerShell로 현재 사용자에 대한 임시 디렉토리의 위치를​ 어떻게​ 얻나요?
[System.IO.Path]::GetTempPath()

PowerShell로 경로와 하위 경로를 단일 경로로 어떻게 연결하나요?
Join-Path -Path C:\ -ChildPath \windows

PowerShell로 모든 cmdlet “Get-*”를 ​​어떻게 나열하나요?
Get-Command -Verb Get

PowerShell로 특별 시스템 폴더를 어떻게 나열하나요?

PowerShell로 ISO / VHD 파일을 어떻게 마운트하나요?
Mount-DiskImage 'D:\ISO\file.iso' # ISO
Mount-DiskImage 'D:\VHD\file.vhd' # VHD

PowerShell로 설치된 .NET Framework 버전을 어떻게 확인하나요?

PowerShell로 .NET Framework 버전 4.5 설치 여부를 어떻게 확인하나요?
(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full' -EA 0).Version -like '4.5*'

PowerShell로 (Windows PowerShell 세션의 기록을 생성하기 위해) 트랜스크립트를 어떻게 시작 및 중지하나요?
Start-Transcript -Path 'C:\scripts\transcript.txt
Stop-Transcript

PowerShell로 현 디렉토리를 특정 위치로 어떻게 변경하나요?
Set-Location -Path 'C:\scripts'

PowerShell로 화면을 어떻게 지우나요?
Clear-Host
cls # Alias

PowerShell로 디스플레이 해상도를 어떻게 변경하나요?
Set-DisplayResolution -Width 1280 -Height 1024 -Force # Windows 2012

PowerShell로 “full screen” 창을 어떻게 설정하나요?
mode.com 300

PowerShell로 사진의 크기 (폭과 높이)를 어떻게 얻나요?

PowerShell로 Windows 제품 키를 어떻게 얻나요?

Perfmon

PowerShell로 지난 5 초 (10 회)의 현 “% Processor Time” (평균)을 어떻게 얻나요?
(Get-Counter '\Processor(_total)\% Processor Time' -SampleInterval 5 -MaxSamples 10).CounterSamples.CookedValue

Assemblies

PowerShell로 어셈블리를 어떻게 로드하나요?

PowerShell로 로드 된 현 .NET 어셈블리를 어떻게 확인하나요?

PowerShell로 GAC (Global Assembly Cache) 경로를 어떻게 찾나요?

Clipboard

PowerShell로 클립 보드에 결과를 어떻게 복사하나요?

PowerShell로 클립 보드의 내용을 어떻게 얻나요?
Add-Type -AssemblyName PresentationCore
[Windows.Clipboard]::GetText()

Hotfixes

PowerShell로 설치 된 핫픽스를 어떻게 얻나요?
Get-HotFix -ComputerName $computer

PowerShell로 특정 날짜 이전/이후에 설치 된 핫픽스를 어떻게 얻나요?
Get-HotFix | Where-Object -FilterScript { $_.InstalledOn -lt ([DateTime]'01/01/2015') } # Before 01/01/2015
Get-HotFix | Where-Object -FilterScript {$_.InstalledOn -gt ([DateTime]'01/01/2015')} # After 01/01/2015

PowerShell로 핫픽스 설치 여부를 어떻게 확인하나요?
Get-HotFix -Id KB2965142

PowerShell로 원격 컴퓨터에 설치 된 핫픽스를 어떻게 얻나요?
Get-HotFix -ComputerName $computer

Pagefile

PowerShell로 페이지파일의 정보를 어떻게 얻나요?
Get-WmiObject -Class Win32_PageFileusage | Select-Object -Property Name, CurrentUsage, AllocatedBaseSize, PeakUsage, InstallDate

PowerShell로 페이지파일의 권장 크기 (MB)를 어떻게 얻나요?
[Math]::Truncate(((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) / 1MB) * 1.5

PowerShell로 (D:) 드라이브에 페이지파일 (4096 MD)을 어떻게 생성하나요?

PowerShell로 (C:) 드라이브에 페이지파일을 어떻게 삭제하나요?

Maintenance

PowerShell로 드라이브의 단편화를 어떻게 확인하나요?

PowerShell로 드라이브의 디스크 공간을 어떻게 확인하나요?

Up


Files

PowerShell로 파일을 어떻게 여나요?
Invoke-Item -Path 'C:\scripts\file.txt'
.'C:\scripts\file.txt'

PowerShell로 파일을 어떻게 읽나요?
Get-Content -Path 'C:\scripts\file.txt'
gc "C:\scripts\file.txt" # Alias

PowerShell로 파일에 아웃풋을 어떻게 작성하나요?

PowerShell로 현 스크립트 파일의 전체 이름을 어떻게 얻나요?
$MyInvocation.MyCommand.Path

PowerShell로 파일을 어떻게 압축하나요?

PowerShell로 파일을 어떻게 압축 해제하나요?

PowerShell로 ZIP 아카이브에있는 파일을 어떻게 보나요?
Add-Type -AssemblyName 'System.IO.Compression.Filesystem'
[System.IO.Compression.ZipFile]::OpenRead($fileZIP)

PowerShell로 파일의 크기를 KB로 어떻게 표시하나요?
(Get-ChildItem -Path .\winsrv.dll).Length /1KB
(Get-ChildItem -Path .\winsrv.dll).Length /1MB
(Get-ChildItem -Path .\winsrv.dll).Length /1GB

PowerShell로 1 GB 이상 또는 이하 파일을 어떻게 찾나요?

PowerShell로 확장자가 없는 파일명을 어떻게 표시하나요?
[System.IO.Path]::GetFileNameWithoutExtension('C:\Windows\system32\calc.exe') # Return calc

PowerShell로 파일의 확장자를 어떻게 표시하나요?
[System.IO.Path]::GetExtension('C:\scripts\file.txt') # Return .txt

PowerShell로 파일의 파일 버전을 어떻게 얻나요?

PowerShell로 파일 해시를 어떻게 얻나요?
(Get-FileHash $file).Hash

PowerShell로 파일의 MD5 / SHA1 체크섬을 어떻게 얻나요?
Get-FileHash $file -Algorithm MD5
Get-FileHash $file -Algorithm SHA1

PowerShell로 숨겨진 파일을 어떻게 표시하나요?

PowerShell로 파일의 확장자 유무를 어떻게 확인하나요?

PowerShell로 “Read Only” 파일을 어떻게 설정하나요?
Set-ItemProperty -Path .\file.txt -Name IsReadOnly -Value $true

PowerShell로 파일에 대한 “LastWriteTime” 속성을 지난 주로 어떻게 변경하나요?
Set-ItemProperty -Path .\file.txt -Name LastWriteTime -Value ((Get-Date).AddDays(-7))
If not working, use Nirsoft tool: BulkFileChanger.

PowerShell로 새 파일을 어떻게 생성하나요?
New-Item -ItemType File -Path 'C:\scripts\file.txt' -Value 'FirstLine'

PowerShell로 파일을 이름을 어떻게 변경하나요?
Rename-Item -Path 'C:\scripts\file.txt' -NewName 'C:\scripts\powershellguru2.txt'

PowerShell로 여러 파일명을 어떻게 일괄 변경하나요?
Get-ChildItem -Path C:\scripts\txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }

PowerShell로 파일을 어떻게 삭제하나요?
Remove-Item -Path 'C:\scripts\file.txt'

PowerShell로 파일의 10 최신 라인을 어떻게 표시하나요?
Get-Content -Path 'C:\scripts\log.txt' -Tail 10

PowerShell로 폴더의 여러 파일을 어떻게 잠금 해제하나요?
Get-ChildItem -Path 'C:\scripts\Modules' | Unblock-File

PowerShell로 파일에서 빈 줄을 어떻게 제거하나요?
(Get-Content -Path file.txt) | Where-Object -FilterScript {$_.Trim() -ne '' } | Set-Content -Path file.txt

PowerShell로 파일의 존재 여부를 어떻게 확인하나요?

PowerShell로 폴더의 가장 최신 / 가장 오래 된 파일을 어떻게 얻나요?

PowerShell로 파일에서 중복 라인을 어떻게 제거하나요?

PowerShell로 폴더의 생성 1 개월 이상 또는 미만 파일을 어떻게 얻나요?

PowerShell로 폴더의 생성 1 년 이상 또는 미만 파일을 어떻게 얻나요?

PowerShell로 파일에 변수 값을 어떻게 내보내나요?
Set-Content -Path file.txt -Value $variable

PowerShell로 폴더에 있는 파일의 수 (*.txt)를 어떻게 계산하나요?

PowerShell로 여러 개의 파일 내부 스트링을 어떻게 검색하나요?
Select-String -Path 'C:\*.txt' -Pattern 'Test'

PowerShell로 파일의 첫 번째 / 마지막 줄을 어떻게 표시하나요?

PowerShell로 파일의 특정 라인 번호를 어떻게 표시하나요?

PowerShell로 파일의 라인 수를 어떻게 계산하나요?

PowerShell로 파일의 글자와 단어의 수를 어떻게 계산하나요?

PowerShell로 파일을 어떻게 다운로드하나요?
Invoke-WebRequest -Uri 'http://www.nirsoft.net/utils/searchmyfiles.zip' -OutFile 'C:\tools\searchmyfiles.zip'

PowerShell로 파일의 전체 경로를 어떻게 표시하나요?
Resolve-Path -Path .\script.ps1 # Return C:\Scripts\script.ps1

Copy

PowerShell로 하나의 폴더에 하나의 파일을 어떻게 복사하나요?
Copy-Item -Path 'C:\source\file.txt' -Destination 'C:\destination'

PowerShell로 여러 폴더에 하나의 파일을 어떻게 복사하나요?

PowerShell로 하나의 폴더에 여러 파일을 어떻게 복사하나요?
Get-ChildItem -Path 'C:\source' -Filter *.txt | Copy-Item -Destination 'C:\destination'

Up


Active Directory

Domain & Forest

Computers

Groups

Organizational Unit (OU)

Users

Domain & Forest

PowerShell로 Active Directory의 Global Catalog 서버를 어떻게 찾나요?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs

PowerShell로 Active Directory의 사이트를 어떻게 찾나요?
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites

PowerShell로 현 도메인 컨트롤러를 어떻게 찾나요?

PowerShell로 도메인의 모든 도메인 컨트롤러를 어떻게 찾나요?

PowerShell로 AD 복제 오류를 어떻게 찾나요?
Get-ADReplicationFailure dc02.domain.com # Windows 8 and 2012

PowerShell로 Active Directory의 포레스트에 대한 툼스톤 수명을 어떻게 찾나요?

PowerShell로 Active Directory의 포레스트 / 도메인의 정보를 어떻게 얻나요?

PowerShell을 Active Directory의 “Deleted Objects” 컨테이너의 경로를 어떻게 얻나요?
(Get-ADDomain).DeletedObjectsContainer

PowerShell로 Active Directory의 AD 휴지통 기능을 어떻게 활성화하나요?

PowerShell로 Active Directory의 휴지통에서 AD 계정을 어떻게 복원하나요?
Get-ADObject -Filter 'samaccountname -eq "powershellguru"' -IncludeDeletedObjects | Restore-ADObject

PowerShell로 FSMO 역할을 어떻게 찾나요?

PowerShell로 특정 도메인 컨트롤러에 어떻게 연결하나요?
Get-ADUser -Identity $user -Server 'serverDC01'

PowerShell로 현 로그온 서버를 어떻게 얻나요?

PowerShell로 컴퓨터에서 “gpupdate”를 어떻게 수행하나요?
Invoke-GPUpdate -Computer $computer -Force -RandomDelayInMinutes 0 # Windows 2012

Groups

PowerShell로 Active Directory의 새 그룹을 어떻게 생성하나요?

PowerShell로 Active Directory의 그룹을 어떻게 삭제하나요?
Remove-ADGroup -Identity 'PowershellGuru'

PowerShell로 Active Directory의 그룹에 사용자를 어떻게 추가하나요?
Add-ADGroupMember "Powershell Guru" -Members powershellguru

PowerShell로 Active Directory의 그룹에서 사용자를 어떻게 제거하나요?
Remove-ADGroupMember 'Powershell Guru' -Members powershellguru

PowerShell로 Active Directory의 (멤버가 없는) 빈 그룹을 어떻게 찾나요?
Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}

PowerShell로 Active Directory의 (멤버가 없는) 빈 그룹을 어떻게 계산하나요?
(Get-ADGroup -Filter * -Properties Members | Where-Object -FilterScript {-not $_.Members}).Count

PowerShell로 Active Directory의 그룹의 멤버를 어떻게 얻나요?

PowerShell로 Active Directory의 재귀 멤버 그룹의 멤버를 어떻게 얻나요?

PowerShell로 Active Directory의 재귀 멤버가 있는 / 없는 그룹의 멤버 수를 어떻게 계산하나요?

Users

PowerShell로 Active Directory의 “GET-ADUser”의 필터에 와일드 카드를 어떻게 사용하나요?

PowerShell로 Active Directory의 다른 OU에 사용자를 어떻게 이동하나요?
Move-ADObject -Identity $dn -TargetPath 'OU=myOU,DC=domain,DC=com'

PowerShell로 사용자에 대해 (Nested) 모든 멤버를 어떻게 찾나요?
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=$($dn))"

PowerShell로 사용자에 대해 (short name / truncated) 멤버를 어떻게 얻나요?
(Get-ADUser -Identity $user -Properties MemberOf).MemberOf | ForEach-Object -Process {($_ -split ',')[0].Substring(3)} | Sort-Object

PowerShell로 Active Directory의 사용자 계정에 대한 이름 (전체 이름), (표시 이름), 이름 (이름), 및 성 (성)을 어떻게 변경하나요?

PowerShell로 Active Directory의 사용자 계정에 대한 설명, 사무실 및 전화 번호를 어떻게 변경하나요?
Set-ADUser $samAccountName -Description 'IT Consultant' -Office 'Building B' -OfficePhone '12345'

PowerShell로 Active Directory의 사용자 계정에 대한 만료 날짜를 “31/12/2015” 또는 “Never”로 어떻게 설정하나요?

PowerShell로 Active Directory의 사용자 계정을 어떻게 잠금 해제하나요?
Unlock-ADAccount $samAccountName

PowerShell로 Active Directory의 사용자 계정을 어떻게 활성화 / 비활성화하나요?

PowerShell로 Active Directory의 사용자 계정을 어떻게 삭제하나요?
Remove-ADUser $samAccountName

PowerShell로 Active Directory의 하나의 사용자 계정에 대한 비밀번호를 어떻게 재설정하나요?

PowerShell로 Active Directory의 여러 사용자 계정에 대한 비밀번호를 어떻게 재설정하나요?

PowerShell로 Active Directory의 파일의 소유자를 어떻게 찾나요?

PowerShell로 Active Directory의 사용자에 대한 OU (Organizational Unit)를 어떻게 찾나요?
[regex]::match("$((Get-ADUser -Identity $user -Properties DistinguishedName).DistinguishedName)",'(?=OU=)(.*\n?)').value

PowerShell로 Active Directory의 비활성화 사용자 계정을 어떻게 찾나요?

PowerShell로 Active Directory의 만료 된 사용자 계정을 어떻게 찾나요?
Search-ADAccount -AccountExpired

PowerShell로 Active Directory의 잠긴 사용자 계정을 어떻게 찾나요?
Search-ADAccount -LockedOut

PowerShell로 Active Directory의 사용자 계정의 SID를 어떻게 찾나요?
(Get-ADUser -Identity $user -Properties SID).SID.Value

PowerShell로 Active Directory의 사용자명을 SID로 어떻게 변환하나요?

PowerShell로 Active Directory의 SID를 사용자명으로 어떻게 변환하나요?

PowerShell로 Active Directory의 사용자 계정의 고유 이름을 어떻게 분할하나요?

PowerShell로 Active Directory의 사용자 계정의 생성 / 수정 날짜를 어떻게 찾나요?
Get-ADUser -Identity $user -Properties whenChanged, whenCreated | Format-List -Property whenChanged, whenCreated

PowerShell로 Active Directory의 클래스 “사용자”에 대한 선택 및 필수 속성을 어떻게 표시하나요?

PowerShell로 Active Directory의 사용자에 대한 LDAP 경로를 어떻게 얻나요?

PowerShell로 Active Directory의 사용자에 대한 CN (Canonical Name)을 어떻게 변경하나요?
Rename-ADObject $((Get-ADUser -Identity $user -Properties DistinguishedName).DistinguishedName) -NewName 'Test Powershell'

PowerShell로 Active Directory의 사용자의 Organizational Unit (OU) 상위를 어떻게 얻나요?

PowerShell로 Active Directory의 (계정을 만든) 사용자의 소유자를 어떻게 얻나요?

PowerShell로 Active Directory의 사용자에 대한 PwdLastSet 속성을 어떻게 변환하나요?

Computers

PowerShell로 로컬 컴퓨터와 도메인 간의 보안 채널을 어떻게 테스트하나요?
Test-ComputerSecureChannel

PowerShell로 로컬 컴퓨터와 도메인 간의 보안 채널을 어떻게 복구하나요?
Test-ComputerSecureChannel -Repair

PowerShell로 Active Directory의 컴퓨터 계정을 어떻게 비활성하나요?
Disable-ADAccount $computer

PowerShell로 Active Directory의 특정 운영 체제 컴퓨터를 어떻게 찾나요?

Organizational Unit (OU)

PowerShell로 Active Directory의 Organizational Unit (OU)을 어떻게 생성하나요?
New-ADOrganizationalUnit -Name 'TEST' -Path 'DC=domain,DC=com'

PowerShell로 Active Directory의 Organizational Unit (OU) 정보를 어떻게 얻나요?
Get-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Properties *

PowerShell로 Active Directory의 Organizational Unit (OU)의 설명을 어떻게 변경하나요?
Set-ADOrganizationalUnit 'OU=TEST,DC=domain,DC=com' -Description 'My description'

PowerShell로 Active Directory의 실수 삭제로부터 Organizational Unit (OU)을 어떻게 활성화 / 비활성화하나요?

PowerShell로 Active Directory의 모든 Organizational Unit (OU)에 대한 실수 삭제를 어떻게 활성화하나요?

PowerShell로 Active Directory의 실수 삭제로부터 보호 된 Organizational Unit (OU)을 어떻게 삭제하나요?

PowerShell로 Active Directory의 Organizational Unit (OU)의 DistinguishedName을 CanonicalName로 어떻게 변환하나요?

PowerShell로 빈 Organizational Units (OUs)을 어떻게 나열하나요?

PowerShell로 그룹의 매니저를 어떻게 얻나요?
(Get-ADGroup $dn -Properties Managedby).Managedby

Up


Regex (Regular Expression)

PowerShell로 Regex을 사용하여 IP 주소 V4 (80.80.228.8)를 어떻게 압축 해제하나요?
$example = 'The IP address is 80.80.228.8'
$ip = [regex]::match($example,'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b').value

PowerShell로 Regex을 사용하여 분리기 “-“를 사용한 MAC 주소 (C0-D9-62-39-61-2D)를 어떻게 압축 해제하나요?
$example = 'The MAC address is C0-D9-62-39-61-2D'
$mac = [regex]::match($example,'([0-9A-F]{2}[-]){5}([0-9A-F]{2})').value

PowerShell로 Regex을 사용하여 분리기 “-“를 사용한 MAC 주소 (C0:D9:62:39:61:2D)를 어떻게 압축 해제하나요?
$example = 'The MAC address is C0:D9:62:39:61:2D'
$mac = [regex]::match($example,'((\d|([a-f]|[A-F])){2}:){5}(\d|([a-f]|[A-F])){2}').value

PowerShell로 Regex을 사용하여 날짜 (10/02/2015)를 어떻게 압축 해제하나요?
$example = 'The date is 10/02/2015'
$date = [regex]::match($example,'(\d{2}\/\d{2}\/\d{4})').value

PowerShell로 Regex을 사용하여 URL (www.powershell-guru.com)을 어떻게 압축 해제하나요?
$example = 'The URL is www.powershell-guru.com'
$url = [regex]::match($example,'[a-z]+[:.].*?(?=\s)').value

PowerShell로 Regex을 사용하여 이메일 (user@domain.com)을 어떻게 압축 해제하나요?
$example = 'The email is user@domain.com'
$email = [regex]::match($example,'(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b').value

PowerShell로 Regex을 사용하여 스트링 예에서 “guru”를 어떻게 압축 해제하나요?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?=.com)').value

PowerShell로 Regex을 사용하여 스트링 예에서 “guru.com”을 어떻게 압축 해제하나요?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=-)(.*\n?)(?<=.)').value

PowerShell로 Regex을 사용하여 스트링 예에서 “powershell-guru.com”을 어떻게 압축 해제하나요?
$example = 'www.powershell-guru.com'
[regex]::match($example,'(?<=www.)(.*\n?)').value

PowerShell로 Regex을 사용하여 스트링 예에서 “123”을 어떻게 압축 해제하나요?
$example = 'Powershell123'
[regex]::match($example,'(\d+)').value

PowerShell로 Regex을 사용하여 스트링 예에서 “$” (달러 기호)를 어떻게 압축 해제하나요?
$example = 'Powershell`$123'
[regex]::match($example,'(\$)').value

PowerShell로 Regex을 사용하여 스트링의 문자 (*.com)를 다른 문자 (*.fr)로 어떻게 변경하나요?
$example = 'www.powershell-guru.com'
[regex]::Replace($example, '.com','.fr')

PowerShell의 Regex을 사용하여 스트링을 어떻게 탈출하나요?
[regex]::Escape('\\server\share')

Up


Memory

PowerShell로 가비지 컬렉터에 의해 메모리를 어떻게 강제로 수집하나요?
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

PowerShell로 컴퓨터의 RAM 크기를 어떻게 얻나요?

Up


Date

PowerShell로 현재 날짜를 어떻게 얻나요?
Get-Date
[Datetime]::Now

PowerShell로 날짜를 다른 형식으로 어떻게 표시하나요?

PowerShell로 날짜 (Datetime)를 날짜 (String)로 어떻게 변환하나요?

PowerShell로 날짜 (String)를 날짜 (Datetime)로 어떻게 변환하나요?

PowerShell로 두 날짜 간의 차이 (일, 시간, 분, 또는 초 수)를 어떻게 계산하나요?
(New-TimeSpan -Start $dateStart -End $dateEnd).Days
(New-TimeSpan -Start $dateStart -End $dateEnd).Hours
(New-TimeSpan -Start $dateStart -End $dateEnd).Minutes
(New-TimeSpan -Start $dateStart -End $dateEnd).Seconds

PowerShell로 두 날짜를 어떻게 비교하나요?
(Get-Date 2015-01-01) -lt (Get-Date 2015-01-30) # True
(Get-Date 2015-01-01) -gt (Get-Date 2015-01-30) # False

PowerShell로 날짜의 배열을 “Datetime”로 어떻게 정렬하나요?
$arrayDate | Sort-Object -Property {$_ -as [Datetime]}

PowerShell로 스톱워치를 어떻게 시작 및 정지하나요?
$chrono = [Diagnostics.Stopwatch]::StartNew()
$chrono.Stop()
$chrono

PowerShell로 이번 주 오늘의 요일을 어떻게 얻나요?
(Get-Date).DayOfWeek #Sunday

PowerShell로 어제 날짜를 어떻게 얻나요?
(Get-Date).AddDays(-1)

PowerShell로 (2015 년 2 월)의 총 일 수를 어떻게 얻나요?
[DateTime]::DaysInMonth(2015, 2)

PowerShell로 윤년을 어떻게 알 수 있나요?
[DateTime]::IsLeapYear(2015)

PowerShell로 타임 존을 어떻게 나열하나요?
[System.TimeZoneInfo]::GetSystemTimeZones()

Up


Networking

PowerShell로 URL을 어떻게 인코드 (ASCII 형식으로) 및 디코드하나요?

PowerShell를 사용한 기본 네트워크 명령의 등가물은 무엇인가요?

PowerShell로 IP 주소를 어떻게 얻나요?
Get-NetIPAddress # Windows 8.1 & Windows 2012
Get-NetIPConfiguration # Windows 8.1 & Windows 2012

PowerShell로 IP 주소 v6 (IPv6)를 어떻게 비활성화하나요?

PowerShell로 IP 주소 v4 (IPv4)를 어떻게 확인하나요?
if([ipaddress]'10.0.0.1'){'validated'}

PowerShell로 외부 IP 주소를 어떻게 찾나요?

PowerShell로 IP 주소에서 Hostname을 어떻게 찾나요?
([System.Net.Dns]::GetHostEntry($IP)).Hostname

PowerShell로 Hostname에서 IP 주소를 어떻게 찾나요?
([System.Net.Dns]::GetHostAddresses($computer)).IPAddressToString

PowerShell로 Hostname에서 FQDN을 어떻게 찾나요?
[System.Net.Dns]::GetHostByName($computer).HostName

PowerShell로 네트워크 구성 (Ip, Subnet, Gateway, 및 DNS)을 어떻게 찾나요?

PowerShell로 MAC 주소를 어떻게 찾나요?
Get-CimInstance win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress
Get-WmiObject -Class win32_networkadapterconfiguration | Select-Object -Property Description, Macaddress

PowerShell로 컴퓨터의 통신 상태를 어떻게 확인하나요?

PowerShell로 컴퓨터의 인터넷 연결 여부를 어떻게 확인하나요?

PowerShell로 웹사이트에 대한 “whois” 조회를 어떻게 수행하나요?
$whois = New-WebServiceProxy 'http://www.webservicex.net/whois.asmx?WSDL'
$whois.GetWhoIs('powershell-guru.com')

PowerShell로 공용 IP의 정보 (위치 ​​정보)를 어떻게 얻나요?

PowerShell로 포트의 개방 / 폐쇄 여부를 어떻게 확인하나요?
New-Object -TypeName Net.Sockets.TcpClient -ArgumentList $computer, 135

PowerShell로 “tracert”를 어떻게 수행하나요?
Test-NetConnection www.google.com -TraceRoute

PowerShell로 홈 네트워크 연결 프로필을 어떻게 수정하나요?
Get-NetAdapter | Format-Table -Property Name, InterfaceDescription, ifIndex -AutoSize # Windows 8.1
Set-NetConnectionProfile -InterfaceIndex 6 -NetworkCategory Private

PowerShell로 TCP 포트 연결을 어떻게 표시하나요?
netstat.exe -ano
Get-NetTCPConnection #Windows 8 and 2012

PowerShell로 긴 URL을 짧은 URL로 어떻게 단축하나요?
$url = 'www.powershell-guru.com'
$tiny = Invoke-RestMethod -Uri "http://tinyurl.com/api-create.php?url=$url"

PowerShell로 프록시 설정을 어떻게 얻나요?
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

DNS

PowerShell로 로컬 컴퓨터의 DNS 캐시를 어떻게 확인하나요?
ipconfig.exe /displaydns
Get-DnsClientCache #Windows 8 and 2012

PowerShell로 로컬 컴퓨터의 DNS 캐시를 어떻게 삭제하나요?
ipconfig.exe /flushdns
Start-Process -FilePath ipconfig -ArgumentList /flushdns -WindowStyle Hidden
Clear-DnsClientCache #Windows 8 and 2012

PowerShell로 원격 컴퓨터의 DNS 캐시를 어떻게 삭제하나요?
Invoke-Command -ScriptBlock {Clear-DnsClientCache} -ComputerName computer01, computer02

PowerShell로 호스트 파일을 어떻게 읽나요?
Get-Content -Path 'C:\Windows\system32\drivers\etc\hosts'

Up


Password

PowerShell로 랜덤 비밀번호를 어떻게 생성하나요?
[Reflection.Assembly]::LoadWithPartialName('System.Web')
[System.Web.Security.Membership]::GeneratePassword(30,2)

PowerShell로 원격 서버의 관리자에 대한 로컬 암호를 어떻게 변경하나요?
$admin = [ADSI]('WinNT://server01/administrator,user')
$admin.SetPassword($password)
$admin.SetInfo()

PowerShell로 Active Directory의 계정의 비밀번호 만료 날짜를 어떻게 찾나요?

Up


Printers

PowerShell로 특정 서버에 대한 모든 프린터를 어떻게 나열하나요?
Get-WmiObject -Query 'Select * From Win32_Printer' -ComputerName $computer

PowerShell로 특정 서버에 대한 모든 포트를 어떻게 나열하나요?
Get-WmiObject -Class Win32_TCPIPPrinterPort -Namespace 'root\CIMV2' -ComputerName $computer

PowerShell로 프린터의 코멘트 / 위치를 어떻게 변경하나요?

PowerShell로 프린터 (모든 작업 취소)를 어떻게 제거하나요?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.CancelAllJobs()

PowerShell로 프린터 테스트 페이지를 어떻게 인쇄하나요?
$printer = Get-WmiObject -Class win32_printer -Filter "Name='HP Deskjet 2540 series'"
$printer.PrintTestPage()

PowerShell로 프린터 인쇄 대기열을 어떻게 얻나요?

Up


Regedit

Read

PowerShell로 레지스트리 하이브를 어떻게 나열하나요?
Get-ChildItem -Path Registry::

PowerShell로 레지스트리 값과 값 유형을 어떻게 얻나요?

PowerShell로 레지스트리 키의 서브키를 어떻게 나열하나요?

PowerShell로 재귀 방법으로 레지스트리 키의 서브키를 어떻게 나열하나요?
Get-ChildItem -Path 'HKLM:\SYSTEM' -Recurse -ErrorAction SilentlyContinue

PowerShell로 특정 이름의 서브키를 어떻게 찾나요?
Get-ChildItem -Path 'HKLM:\SOFTWARE' -Include *Plugin* -Recurse -ErrorAction SilentlyContinue

PowerShell로 레지스트리 서브키의 이름만 어떻게 되돌리나요?
(Get-ChildItem -Path 'HKLM:\SYSTEM').Name # Return HKEY_LOCAL_MACHINE\SYSTEM\ControlSet
Get-ChildItem -Path 'HKLM:\SYSTEM' -Name # Return ControlSet

PowerShell로 레지스트리 값을 어떻게 나열하나요?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'

PowerShell로 특정 레지스트리 값을 어떻게 읽나요?
(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ProductName

PowerShell로 원격 컴퓨터의 특정 레지스트리 값을 어떻게 읽나요?

Write

PowerShell로 새 레지스트리 키를 어떻게 생성하나요?
New-Item -Path 'HKCU:\Software\MyApplication'

PowerShell로 레지스트리 값을 어떻게 생성하나요?
New-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '1.0'

PowerShell로 기존 레지스트리 값을 어떻게 수정하나요?
Set-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version' -Value '2.0'

Delete

PowerShell로 레지스트리 값을 어떻게 삭제하나요?
Remove-ItemProperty -Path 'HKCU:\Software\MyApplication' -Name 'Version'

PowerShell로 레지스트리 키를 어떻게 삭제하나요?
Remove-Item -Path 'HKCU:\Software\MyApplication' -Force

Test

PowerShell로 레지스트리 키 존재 여부를 어떻게 테스트하나요?
Test-Path -Path 'HKCU:\Software\MyApplication'

PowerShell로 레지스트리 값 존재 여부를 어떻게 테스트하나요?
(Get-Item -Path 'HKCU:\Software\MyApplication').GetValueNames() -contains 'Version'

Up


Strings

PowerShell로 스트링의 시작에서 공백을 어떻게 제거하나요?
$string = ' PowershellGuru'
$string = $string.TrimStart()

PowerShell로 스트링의 끝에서 공백을 어떻게 제거하나요?
$string = 'PowershellGuru '
$string = $string.TrimEnd()

PowerShell로 스트링의 (시작 및 끝에서) 공백을 어떻게 제거하나요?
$string = ' PowershellGuru '
$string = $string.Trim()

PowerShell로 스트링을 대문자로 어떻게 변환하나요?
$string = 'powershellguru'
$string = $string.ToUpper()

PowerShell로 스트링을 소문자로 어떻게 변환하나요?
$string = 'POWERSHELLGURU'
$string = $string.ToLower()

PowerShell로 스트링 “PowerShellGuru”의 서브스트링 “PowerShell”을 어떻게 선택하나요?
$string.Substring(0,10)

PowerShell로 스트링 “PowerShellGuru”의 서브스트링 “Guru”를 어떻게 선택하나요?
$string.Substring(10)

PowerShell로 “PowerShell123Guru”의 숫자 “123”을 어떻게 선택하나요?
$string = 'Powershell123Guru'
[regex]::match($string,'(\d+)').value

PowerShell로 스트링 “PowerShellGuru”의 제로-베이스드 인덱스 “Guru”를 어떻게 얻나요?
$string.IndexOf('Guru') # 10

PowerShell로 스트링이 비어 있는지를 어떻게 확인하나요?
$string = $null
$string = ''
[string]::IsNullOrEmpty($string)

PowerShell로 스트링이 비어있거나 공백으로만 구성되어 있는지를 어떻게 확인하나요?
$string = $null
$string = ''
$string = ' '
[string]::IsNullOrWhiteSpace($string)

PowerShell로 스트링이 특정 문자를 포함하는지 어떻게 확인하나요?
$string = 'PowershellGuru'
$string.Contains('s')
[regex]::match($string,'s').Success

PowerShell로 스트링의 길이를 어떻게 되돌리나요?
$string.Length

PowerShell로 두 스트링을 어떻게 연결하나요?

PowerShell로 스트링의 하나 또는 여러 개의 괄호 “[ ]”를 어떻게 매치하나요?
$string = '[PowershellGuru]'
$string -match '\[' # Only 1
$string -match '\[(.*)\]' # Several

PowerShell로 스트링의 하나 또는 여러 개의 괄호 “( )”를 어떻게 매치하나요?
$string = '(PowershellGuru)'
$string -match '\(' # Only 1
$string -match '\((.*)\)' # Several

PowerShell로 스트링의 하나 또는 여러 개의 괄호 “{ }”를 어떻게 매치하나요?
$string = '{PowershellGuru}'
$string -match '\{' # Only 1
$string -match '\{(.*)\}' # Several

PowerShell로 스트링의 하나 또는 여러 개의 괄호 “< >”를 어떻게 매치하나요?
$string = ''
$string -match '\<' # Only 1
$string -match "\<(.*)\>" # Several

PowerShell로 스트링의 소문자 (abc)를 어떻게 매치하나요?
$string = 'POWERSHELLGURU'
$string -cmatch "^[a-z]*$" #False

PowerShell로 스트링의 하나 또는 여러 개의 괄호 “< >”를 어떻게 매치하나요?
$string = 'powershellguru'
$string -cmatch "^[A-Z]*$" #False

PowerShell로 스트링의 “[p” (p 소문자)를 어떻게 매치하나요?
$string = '[powershellGuru]'
$string -cmatch '\[[a-z]\w+' #True

PowerShell로 스트링의 “[P” (P 대문자)를 어떻게 매치하나요?
$string = '[PowershellGuru]'
$string -cmatch '\[[A-Z]\w+' #True

PowerShell로 라인을 다른 라인으로 어떻게 교체하나요?
$a = 'Line A'
$b = 'Line B'
$a = $a -replace $a, $b

PowerShell로 분할 작업을 스트링 (퍼센트)으로 어떻게 변환하나요?
(1/2).ToString('P')

PowerShell로 번호를 포함하는 스트링을 어떻게 정렬하나요?

PowerShell로 문장의 마지막 단어를 어떻게 선택하나요?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ')[-1] # Returns Powershell

PowerShell로 문장의 가장 긴 단어를 어떻게 얻나요?
$sentence = 'My name is Test Powershell'
$sentence.Split(' ') | Sort-Object -Property Length | Select-Object -Last 1 # Returns Powershell

PowerShell로 문장 내에 존재하는 스트링의 수를 어떻게 계산하나요?
$sentence = 'test test test Powershell'
[regex]::Matches($sentence, 'test').Count # Returns 3

PowerShell로 스트링의 각 문자를 문자 배열으로 어떻게 복사하나요?

PowerShell로 스트링의 첫 글자를 어떻게 대문자로 변환하나요?

PowerShell로 스트링을 (왼쫀 또는 오른쪽) 패드하나요?

PowerShell로 스트링을 Base64로 어떻게 인코드 및 디코드하나요?

PowerShell로 숫자와 이진수 간을 어떻게 변환하나요?

PowerShell로 경로의 마지막 상위 폴더만 어떻게 되돌리나요?

PowerShell로 경로의 마지막 항목만 어떻게 되돌리나요?

Up


Math

PowerShell로 System.Math 클래스의 수단을 어떻게 나열하나요?
[System.Math] | Get-Member -Static -MemberType Method

PowerShell로 절대 값을 어떻게 되돌리나요?
[Math]::Abs(-12) #Returns 12
[Math]::Abs(-12.5) # Returns 12.5

PowerShell로 지정 된 번호의 각도를 어떻게 되돌리나요?
[Math]::ASin(1) #Returns 1,5707963267949

PowerShell로 올림을 어떻게 되돌리나요?
[Math]::Ceiling(1.4) #Returns 2
[Math]::Ceiling(1.9) #Returns 2

PowerShell로 내림을 어떻게 되돌리나요?
[Math]::Floor(1.4) #Returns 1
[Math]::Floor(1.9) #Returns 1

PowerShell로 지정 된 숫자의 자연 (베이스 e) 대수를 어떻게 되돌리나요?
[Math]::Log(4) #Returns 1,38629436111989

PowerShell로 지정 된 숫자의 베이스 10 대수를 어떻게 되돌리나요?
[Math]::Log10(4) #Returns 0,602059991327962

PowerShell로 두 값의 최대 값을 어떻게 되돌리나요?
[Math]::Max(2,4) #Returns 4
[Math]::Max(-2,-4) #Returns -2

PowerShell로 두 값의 최소값을 어떻게 되돌리나요?
[Math]::Min(2,4) #Returns 2
[Math]::Max(-2,-4) #Returns -4

PowerShell로 지정 된 거듭 제곱 수를 어떻게 되돌리나요?
[Math]::Pow(2,4) #Returns 16

PowerShell로 십진수 값을 가장 가까운 정수 값으로 어떻게 되돌리나요?
[Math]::Round(3.111,2) #Returns 3,11
[Math]::Round(3.999,2) #Returns 4

PowerShell로 지정 된 십진수의 정수 부분을 어떻게 되돌리나요?
[Math]::Truncate(3.111) #Returns 3
[Math]::Truncate(3.999) #Returns 3

PowerShell로 지정 된 숫자의 제곱근을 어떻게 되돌리나요?
[Math]::Sqrt(16) #Returns 4

PowerShell로 PI 상수를 어떻게 되돌리나요?
[Math]::Pi #Returns 3,14159265358979

PowerShell로 자연 대수 베이스 (상수 e)를 어떻게 되돌리나요?
[Math]::E #Returns 2,71828182845905

PowerShell로 숫자가 홀수인지 짝수인지 어떻게 확인하나요?
[bool]($number%2)

Up


Hashtables

PowerShell로 빈 해시테이블을 어떻게 생성하나요?
$hashtable = @{}
$hashtable = New-Object -TypeName System.Collections.Hashtable

PowerShell로 항목 해시 테이블을 어떻게 생성하나요?

PowerShell로 항목의 키/이름 (사전 순서)으로 분류 된 해시테이블을 어떻게 생성하나요?

PowerShell로 항목 (키-값 쌍)을 해시테이블에 어떻게 추가하나요?
$hashtable.Add('Key4', 'Value4')

PowerShell로 해시테이블의 특정 값을 어떻게 얻나요?

PowerShell로 해시테이블의 최소 값을 어떻게 얻나요?

PowerShell로 해시테이블의 최대 값을 어떻게 얻나요?

PowerShell로 해시테이블의 항목을 어떻게 수정하나요?
$hashtable.Set_Item('Key1', 'Value1Updated')

PowerShell로 해시테이블의 항목을 어떻게 삭제하나요?
$hashtable.Remove('Key1')

PowerShell로 해시테이블을 어떻게 삭제하나요?
$hashtable.Clear()

PowerShell로 해시테이블의 특정 키/값의 존재를 어떻게 확인하나요?
$hashtable.ContainsKey('Key3')
$hashtable.ContainsValue('Value3')

PowerShell로 해시테이블의 키/값을 기준으로 어떻게 정렬하나요?
$hashtable.GetEnumerator() | Sort-Object -Property Name
$hashtable.GetEnumerator() | Sort-Object -Property Value -Descending

Up


Arrays

PowerShell로 빈 배열을 어떻게 생성하나요?
$array = @()
$array = [System.Collections.ArrayList]@()

PowerShell로 항목 배열을 어떻게 생성하나요?
$array = @('A', 'B', 'C')
$array = 'A', 'B', 'C'
$array = 'a,b,c'.Split(',')
$array = .{$args} a b c
$array = echo a b c

PowerShell로 항목을 배열에 어떻게 추가하나요?
$array += 'D'
[void]$array.Add('D')

PowerShell로 배열에서 항목을 어떻게 수정하나요?
$array[0] = 'Z' # 1st item[0]

PowerShell로 배열의 크기를 어떻게 확인하나요?
$array = 'A', 'B', 'C'
$array.Length # Returns 3

PowerShell로 배열에서 하나 / 여러 / 모든 항목을 어떻게 검색하나요?
$array = @('A', 'B', 'C')
$array[0] # One item (A)
$array[0] + $array[2] # Several items (A,C)
$array # All items (A,B,C)

PowerShell로 배열에서 빈 항목을 어떻게 제거하나요?
$array = @('A', 'B', 'C', '')
$array = $array.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) | Sort-Object # A,B,C

PowerShell로 배열에 항목이 존재 유무를 어떻게 확인하나요?
$array = @('A', 'B', 'C')
'A' | ForEach-Object -Process {$array.Contains($_)} # Returns True
'D' | ForEach-Object -Process {$array.Contains($_)} # Returns False

PowerShell로 배열에서 항목의 인덱스 번호를 어떻게 찾나요?
$array = @('A', 'B', 'C')
[array]::IndexOf($array,'A') # Returns 0

PowerShell로 배열의 항목 순서를 어떻게 반대로하나요?
$array = @('A', 'B', 'C')
[array]::Reverse($array) # C,B,A

PowerShell로 배열에서 임의의 항목을 어떻게 생성하나요?
$array | Get-Random

PowerShell로 오름차순 / 내림차순으로 배열을 어떻게 정렬하나요?
$array = @('A', 'B', 'C')
$array | Sort-Object # A,B,C