1. 이곳(here)에서 PowerShell Pack을 다운로드 받은 후 MSI 파일을 설치합니다.
2. 파워쉘을 실행합니다.
“Import-Module PowerShellPack”을 실행하여 모듈을 로드하여 사용합니다.
3. 모듈사용법은 Get-Help module을 통해서 확인할 수 있습니다.
Get-Help module
import-module WPK
모듈을 import 후 사용하세요.
아래 스크립트는 Powershell ISE에서 사용하세요
예제 1. 메시지 박스 생성
New-Label “Hello, World” -Show -FontSize 48
예제2. 시계
New-Label -FontSize 24 -On_Loaded {
Register-PowerShellCommand -scriptBlock {
$window.Content.Content = (Get-Date | Out-String).Trim()
} -run -in "0:0:0.5"
} -AsJob
예제 3. 프로세스 모니터?
New-ListView -Width 350 -Height 350 -DataBinding @{
ItemsSource = New-Binding -IsAsync -UpdateSourceTrigger PropertyChanged -Path Output
} -View {
New-GridView -AllowsColumnReorder -Columns {
New-GridViewColumn "Name"
New-GridViewColumn "Id"
}
} -DataContext {
Get-PowerShellDataSource -Script {
Get-Process | ForEach-Object { $_ ; Start-Sleep -Milliseconds 25 }
}
} -On_Loaded {
Register-PowerShellCommand -Run -In "0:0:15" -ScriptBlock {
$window.Content.DataContext.Script = $window.Content.DataContext.Script
}
} -asjob
예제4. 동영상 플레이
New-Window -AllowDrop -On_Drop {
$file = @($_.Data.GetFileDropList())[0]
$this.Content.Source = $file
$this.Content.Play()
} -On_Loaded {
$this.Content.Source = dir "$env:PUBLIC\videos\Sample Videos" -Filter *.wmv |
Get-Random | Select-Object -ExpandProperty Fullname
$this.Content.Play()
} -On_Closing {
$this.Content.Stop()
} {
New-MediaElement -LoadedBehavior Manual
} -asJob
예제 4. Dialog Box
$Name = New-Grid -Rows 2 -Columns 'Auto','1*' {
$TextChanged = {
$firstName = Get-Resource FirstName | Select-Object -ExpandProperty Text
$lastName = Get-Resource LastName | Select-Object -ExpandProperty Text
$this.Parent.Tag = "$LastName, $FirstName"
}
New-Label "First Name"
New-TextBox -Name FirstName -Column 1 -On_Loaded {
Set-Resource -Name FirstName -Value $this -Depth -1
} -On_TextChanged $TextChanged
New-Label "Last Name" -Row 1
New-TextBox -Name LastName -Column 1 -Row 1 -On_Loaded {
Set-Resource -Name LastName -Value $this -Depth -1
} -On_TextChanged $TextChanged
} -show
입력 결과 : $name
IsePack - PowerShell ISE에 모듈입니다. 다양한 단축키를 지원합니다.
예제
Command |
Shortcut |
Description |
Add-InlineHelp |
ALT + H |
Quickly insert inline help into your functions so that Get-Help can help other users figure out how to use your code |
Copy-Colored |
CTRL + ALT + C |
Email scripts to your colleagues in rich color |
Copy-ColoredHTML |
CTRL + ALT + SHIFT + C |
Blog out the scripts that you write with Copy-ColoredHTML |
Show-Syntax |
ALT + Y |
Select a command and press ALT + Y to see the syntax |
Show-Member |
ALT + M |
Select a variable and pipe to Get-Member and Out-GridView with ALT+M |
FileSystem - 디스크용량 체크,ZIP 압축파일 지원,드라이브명 변경등 파일 시스템 관련 작업을 지원합니다.
You can use the filesystem module to check free disk space, create and add to zip files, watch locations on the filesystem, find duplicate files, or rename drives.
DotNet - 개발자가 아니라 ... 패스
The DotNet module helps you work with the types loaded on the system. You can use Get-Type to search for loaded .NET types or you can use Get-ProgID to search for loaded COM types. For instance, this one liner will show the fullname property of all types whose short name contains file:
Get-Type | Where-Object { $_.Name –like “*File*” } | Select-Object FullName
You can try creating one of the types with New-Object or getting static members of the type with Get-Member –Static.
To look for COM types, like those used from VBScripts, use something like
PSImageTools - 이미지 파일을 다양하게 지원하는 모듈입니다.
The PSImageTools lets you manage photos of other images using Windows PowerShell. Resize, Rotate, or Crop images, or check out image metadata. Convert to JPEG or Bitmap. Here’s a quick example:
Get-ChildItem $env:UserProfile\Pictures | Get-Image |Get-ImageProperty
PSRSS - RSS를 관리합니다.
PSRss lets you read your RSS feeds from Windows PowerShell. You can subscribe to new feeds, mark articles as read, and get feeds and descriptions. Here’s a quick pipeline to show the 10 most recent RSS articles.
Get-Feed |
Get-Article |
Sort-Object PubDate -Descending |
Select-Object Title, Description -First 10
PSSystemTools - 운영체제 하드웨어,설정 정보등을 확인 할 수 있는 시스템 모듈입니다.
System Tools helps you get hardware and configuration information out of the operating system. Get information about USB devices, processors, boot status, fonts, and more. Check out this quick script to see the USB devices and their manufacturers.
Get-USB |
Select Name, Manufacturer
PSUserTools - 사용자를 관리합니다.
User Tools helps you deal with process elevation and users. You can test to see if the current user is an administrator, start processes that prompt for administrative credentials, get the users on the system, and get detailed information about the current user.
PSCodeGen - Code를 생성합니다.
PSCodeGen is a module to help advanced scripters create code more quickly by automatically generating the code. In PSCodeGen there is New-Enum, which allows you to define a new enumerated type, New-PInvoke, which allows you to work with the C APIs more easily, and New-ScriptCmdlet, which can be used to create new PowerShell advanced functions with ease. Check out these examples of using New-ScriptCmdlet to make new script cmdlets. The first example creates the Start-ProcessAsAdministrator script cmdlet that is in the PSUserTools module
New-ScriptCmdlet -Name Start-ProcessAsAdministrator -FromCommand (Get-Command Start-Process) -RemoveParameter Verb -ProcessBlock {
$null = $psBoundParameters.Verb = "RunAs"
Start-Process @psBoundParameters
}
New-ScriptCmdlet -Name -FromCommand (Get-Command Get-Process) -RemoveParameter Verb
TaskScheduler - 예약 작업을 관리할 수 있습니다.
The TaskScheduler module helps you use the Task Scheduler APIs available on Windows Vista and above to schedule running programs or scripts on your system. You can check running tasks, start tasks on demand. You can also start tasks with an incredible variety of triggers, like single time, daily, weekly, monthly, event log, workstation lock and workstation unlock . Here are some simple examples:
New-task |
Add-TaskTrigger -DayOfWeek Monday, Wednesday, Friday -WeeksInterval 2 -At "3:00 PM" |
Add-TaskAction -Script {
Get-Process | Out-GridView
Start-Sleep -Seconds 100
} |
Register-ScheduledTask TestTask
New-task |
Add-TaskTrigger -In (New-TimeSpan -Seconds 30) |
Add-TaskAction -Script {
Get-Process | Out-GridView
Start-Sleep -Seconds 100
} |
Register-ScheduledTask TestTask
대충 대충 봐도 너무 많네요 .. 휴휴
오늘은 이만~
윈디안이였습니다.
출처 : http://code.msdn.microsoft.com/PowerShellPack