2010. 8. 25. 18:09
안녕하세요 윈디안입니다~

늘 띵가 띵가 놀다가 이맘때가 되면 포스팅을 합니다.

오늘 소개올릴 제품은 Powershell Pack입니다.
홈쇼핑 광고 멘트 같군요;

먼저 이 녀석이 무엇인지 알아야 겠죠?

PowerShell Pack은 파워쉘 스냅인으로 Windows 7 Resource Kit의 일부로 사용되고 있습니다.
10개에 피와 살이될 수 있는 모듈의 집합체입니다.

Module

Description

WPK

Create rich user interfaces quick and easily from Windows PowerShell. Think HTA, but easy. Over 600 scripts to help you build quick user interfaces

TaskScheduler

List scheduled tasks, create or delete tasks

FileSystem

Monitor files and folders, check for duplicate files, and check disk space

IsePack

Supercharge your scripting in the Integrated Scripting Environment with over 35 shortcuts

DotNet

Explore loaded types, find commands that can work with a type, and explore how you can use PowerShell, DotNet and COM together

PSImageTools

Convert, rotate, scale, and crop images and get image metadata

PSRSS

Harness the FeedStore from PowerShell

PSSystemTools

Get Operating System or Hardware Information

PSUserTools

Get the users on a system, check for elevation, and start-processaadministrator

PSCodeGen

Generates PowerShell scripts, C# code, and P/Invoke


번역하려 했으나... 하면 할 수록 말이 꼬여 패스합니다.
원문으로 즐겨주세요.

WPK(Windows PowerShell Kit)

먼저 Channel 9에서 배포하는 동영상입니다.

동영상을 보시면 WPK 이해에 큰 도움이 되실듯 합니다.




그럼 시작해 볼까요?

Windows Powershell v2기반입니다.(Windows7 Windows 2008 R2 Powershell V2 내장되어 있습니다.)

1.0  버전은 사용할 없습니다.

 

1.     곳(here)에서 PowerShell Pack 다운로드 받은 MSI 파일을 설치합니다.

2.     파워쉘을 실행합니다.
“Import-Module PowerShellPack”
실행하여 모듈을 로드하여 사용합니다.

3.     모듈사용법은 Get-Help module 통해서 확인할 있습니다.

Get-Help  module




Powershell Pack을 Import한 상태에서 Get-help module을 사용하면 아래와 같이 help command를 확인 할 수 있습니다.

Import-Module powershellpack
get-help module

Name                              Category  Synopsis                                                                                                                                                                                                                            
----                              --------  --------
New-Module                        Cmdlet    메모리에만 있는 새 동적 모듈을 만듭니다.
Import-Module                     Cmdlet    현재 세션에 모듈을 추가합니다.
Export-ModuleMember               Cmdlet    내보내는 모듈 멤버를 지정합니다.
Get-Module                        Cmdlet    현재 세션으로 가져왔거나 가져올 수 있는 모듈을 검색합니다.
Remove-Module                     Cmdlet    현재 세션에서 모듈을 제거합니다.
New-ModuleManifest                Cmdlet    새 모듈 매니페스트를 만듭니다.
Test-ModuleManifest               Cmdlet    모듈 매니페스트 파일이 모듈의 내용을 정확하게 설명하는지 확인합니다.
about_ISEPack_Module              HelpFile  Describes the ISEPack module in the Windows 7 Resource Kit.                                                                                                                                                                    
about_FileSystem_Module           HelpFile  Describes the FileSystem module in the Windows 7 Resource Kit.
about_PSImageTools_Module         HelpFile  Describes the PSImageTools module in the Windows 7 Resource Kit.
about_PSRSS_Module                HelpFile  Describes the PSRSS module in the Windows 7 Resource Kit.
about_PSUserTools_Module          HelpFile  Describes the PSUserTools module in the Windows 7 Resource Kit.
about_System_Module           HelpFile  Describes the System module in the Windows 7 ResourceKit.
about_modules                     HelpFile  Windows PowerShell 모듈을 설치하고 가져와서 사용하는 방법에 대해 설명합니다.
                                           


예를 들어 ISE 모듈에 대한 설명은 아래와 같이 확인이 가능합니다.                      
   

get-help about_ISEPack_Module         



너무 내용이 많아 자세한 설명 보는 법만 소개했네요

그냥 넘어가기는 그러니 몇개만 볼까요?

WPK - 파워쉘 상에서 인터페이스를 만들어 낼 수 있습니다.
(예제를 실행해 보면 완전 신기합니다!!!)

자세한 설명은 다음 문서를 다운로드 받으세요 -> Writing User Interfaces with WPK.

 

사용법

 

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

Get-ProgID *Image*

 

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

Posted by 알 수 없는 사용자
:
BLOG main image
Windows Server를 공부 하는 사람들의 팀블로그 by 마성민

카테고리

분류 전체보기 (76)
Windows (2)
Powershell (56)
AD (0)
Exchange (6)
System Center (9)
IIS (0)
SQL (3)
Sharepoint (0)

태그목록

Tistory Cumulus Flash tag cloud by BLUEnLIVE requires Flash Player 9 or better.

Total :
Today : Yesterday :