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 알 수 없는 사용자
:
2010. 8. 25. 17:26

안녕하세요. 엉스데브 입니다.

지난번 "PowerShell 을 통해 IIS 관리하기"(링크) 포스트를 통해 잠깐 다뤄봤던 WebAdministration 모듈을 통해
이번엔 FTP 사이트를 만들어 볼까 합니다.(Windows 2008 R2, IIS 7.5 환경 입니다.)

먼저, 파워쉘을 켜고 WebAdministration 모듈을 Import 합니다.



New-WebFtpSite cmdlet 으로 새 FTP 사이트를 만듭니다.


기본적으로 FTP SSL 설정이 무조건 SSL 연결이 필요하도록 되어 있는데, SSL 연결을 사용하지 않을 예정이므로, 변경 해 줍니다.


FTP 인증에 기본 인증(서버의 로컬 계정을 사용해서 로그인)을 사용하도록 설정 해 줍니다.


이제 FTP 에 접속 하게 할 사용자(로컬 계정)를 만들어 주고..(링크 참조)


이 사용자가 해당 FTP 사이트에 접속 권한을 가지도록 권한 부여 규칙을 설정 해 주면, FTP 사이트 만들기가 완료됩니다.


잘 접속 되는지 테스트는 아래와 같이 해 보면 됩니다.


음! 잘 되는군요. ^^

WebConfiguration 관련 cmdlet 을 사용 할 때 가장 어렵게 느껴지는 부분은 
'-Filter' 파라미터로 설정 항목의 경로를 지정 해 주는 부분인것 같습니다.

설정항목의 경로는 applicationHost.config 파일의 내용을 참고로 찾아냅니다.
applicationHost.config 파일은 IIS 의 모든 설정이 정의되어 있는 파일이며,
XML 형식의 파일이라 XML 및 XPath 에 대해 어느정도는 알고 있어야 내용을 파악 및 원하는 경로를 정확히 뽑아 낼 수 있습니다.

아래 명령어로 applicationHost.config 파일을 바로 열어 볼 수 있습니다.


오늘은 여기까지 입니다. 제가 정리한 내용이 보시는 분들께 도움이 되기를 바랍니다.

<참고 URL>
http://www.yusufozturk.info/windows-server/setting-ftp-server-authorization-with-powershell-on-iis7-5.html

Posted by 알 수 없는 사용자
:
2010. 8. 25. 14:35

Exchange Server 2010 설치

Exchange Server 2010의 설치저 요구 사항의 설치가 완료 되면 아래와 같은 순서로 Exchange서버의 설치 작업을 진행 합니다.

자세한 내용은 MS에서 제공하는 technet 및 파트너 팀의 블로그 참고

MS technet : http://technet.microsoft.com/ko-kr/library/bb124778.aspx

파트너 블로그팀 : http://blogs.technet.com/b/koreapartner/archive/2009/10/28/exchange-server-2010-installation-guide.aspx

 

a.     Exchange 언어 옵션을 통하여 언어 설치 선택 후 Microsoft Exchange 설치 클릭 (DVD에서 지원하는 언어 외 추가적인 언어지원이 필요한 경우 언어 번들에서 모든 언어 설치를 선택)

 

b.     소개 내용을 확인 후 다음 클릭


c.     해당 내용 확인 후 동의함 체크 다음 클릭


d.     오류 보고 내용 확인 후 다음 클릭

e.     표준설치 또는 사용자 지정 (각각의 서버 역할을 분리) 설치 경로 지정 후 다음 클릭

f.      사용자 지정의 경우 아래와 같이 각각의 열할을 선택 후 다음 클릭


g.     사용할 조직 이름을 입력 후 다음 클릭


h.     클라이언트 설정에 대한 내용 확인 후 다음 클릭(조직내에 아웃룩2003사용자가 있는경우 예를 체크 없는 경우 아니요 체크)


i.      클라이언트 엑세스 서버에 외부에서 접속할 도메인 입력 후 다음 클릭

j.      사용자 환경 개선 프로그램 내용 확인 후 설문에 참가 유무 선택 후 다음 클릭

k.     설치전 요구 사항에 대한 준비검사 화면


l.      설치전 요구 사항에 대한 준비검사 완료 후 설치 클릭


m.    Exchage 각각의 역할 설치가 완료 되었으며 마침 클릭

여기까지 진행 하였다며 기본적인 Exchange Server 2010 설치는 완료 되었습니다.

Posted by 알 수 없는 사용자
:
2010. 8. 25. 13:26
안녕하세요. 엉스데브 입니다.

PowerShell 에서 zip 파일을 다루기 위한 함수를 몇개

Windows 2008 R2 서버에서 PowerShell 을 이용해 웹 사이트를 구축하는 중입니다.
헌데 소스 파일이 zip 으로 압축 되어 있어서 PowerShell 에서 zip 압축을 풀 수 있는 도구가 필요 했습니다.
구글링을 해 보니, 바로 사용할 수 있는 zip 파일 처리 함수를 몇 개 찾을 수 있었습니다. 아래에 정리 합니다.

1. zip 파일 압축 풀기.
function Extract-Zip
{
  param([string]$zipfilename, [string] $destination)

  if(test-path($zipfilename))
  { 
    $shellApplication = new-object -com shell.application
    $zipPackage = $shellApplication.NameSpace($zipfilename)
    $destinationFolder = $shellApplication.NameSpace($destination)
    $destinationFolder.CopyHere($zipPackage.Items())
  }
}
@ 사용법 : Extract-Zip C:\test\zipfile.zip c:\test\destination

2. zip 압축파일 새로 만들기.
function New-Zip
{
  param([string]$zipfilename)
  set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
  (dir $zipfilename).IsReadOnly = $false
}

3. 이미 존재하는 zip 압축 파일에 파일 추가하기.(파이프 라인 이용)
function Add-Zip
{
  param([string]$zipfilename)
 
  if(-not (test-path($zipfilename)))
  {
    set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
    (dir $zipfilename).IsReadOnly = $false 
  }
 
  $shellApplication = new-object -com shell.application
  $zipPackage = $shellApplication.NameSpace($zipfilename)
 
  foreach($file in $input)
  {
            $zipPackage.CopyHere($file.FullName)
            Start-sleep -milliseconds 500
  }
}

4. zip 파일 내부 파일 목록 확인.
function Get-Zip
{
  param([string]$zipfilename)
  if(test-path($zipfilename))
  {
    $shellApplication = new-object -com shell.application
    $zipPackage = $shellApplication.NameSpace($zipfilename)
    $zipPackage.Items() | Select Path
  }
}

잘 작동하고, 유용하게 사용하고 있습니다. 다만, 경로를 지정 할 때 상대 경로로 지정 할 경우 오류가 발생 하더군요..
전 사용하다 보니 이 부분이 좀 불편해서 아래와 같이 고쳐서 사용하고 있습니다.

# 압축 풀기.
function Extract-Zip
{
  param([string]$zipfilename, [string] $destination=".") #목적지 기본값은 현재 디렉토리

  #상대경로를 절대경로로 변경
  $zipfilename = (Get-Item $zipfilename).FullName
  $destination = (Get-Item $destination).FullName


  if(test-path($zipfilename))
  { 
    $shellApplication = new-object -com shell.application
    $zipPackage = $shellApplication.NameSpace($zipfilename)
    $destinationFolder = $shellApplication.NameSpace($destination)
    $destinationFolder.CopyHere($zipPackage.Items())
  }
}

# 압축 하기
function Add-Zip
{
  param([string]$zipfilename)

  # 파일 명만 지정 했을 때 상대경로로 지정 해 줌.
  if(!$zipfilename.Contains("\"))
  {
    $zipfilename = ".\" + $zipfilename
  }


  if(-not (test-path($zipfilename)))
  {
    set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
    (dir $zipfilename).IsReadOnly = $false 
  }

  #상대경로를 절대경로로 변경
  $zipfilename = (Get-Item $zipfilename).FullName

 
  $shellApplication = new-object -com shell.application
  $zipPackage = $shellApplication.NameSpace($zipfilename)
 
  foreach($file in $input)
  {
            $zipPackage.CopyHere($file.FullName)
            Start-sleep -milliseconds 500
  }
}

profile 파일에 이 함수를 넣어두고 요렇게 사용하면 됩니다.




<참고 URL>
http://blogs.msdn.com/b/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx
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 :