2010. 12. 16. 11:42

PowerShell Pack 을 이용한 스크립트


PowerShell Pack은 파워쉘 스냅인으로 Windows 7 Resource Kit 의 일부로 사용되고 있습니다.

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



* 먼저 PowerShell Pack 사용을 위해 다음 MSDN 에서 다운로드 받을수 있습니다.
http://code.msdn.microsoft.com/PowerShellPack/Release/ProjectReleases.aspx?ReleaseId=3341

Import-Module PowerShellPack   로 모듈을 로드 하여 사용합니다.




MSDN 에서 자료 확인 할 수 있습니다.
http://code.msdn.microsoft.com/PowerShellPack/Release/ProjectReleases.aspx?ReleaseId=3343

WPK 를 이용한 모듈 인포트

import-module WPK


* 메세지 박스


New-Label “Hello, World” -Show -FontSize 48 -AsJob



*  Digital Clock

New-Label -FontSize 24 -On_Loaded {
Register-PowerShellCommand -scriptBlock {     
$window.Content.Content = (Get-Date | Out-String).Trim()
} -run -in "0:0:0.5"
}
-AsJob




* Process Monitor

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


 




* Quick And Easy Modia Player

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


 




출처 : http://code.msdn.microsoft.com/PowerShellPack