Power Shell2009. 10. 7. 11:38

 Windows PowerShell

구글링: Windows PowerShell

 

 http://blogs.msdn.com/powershell/archive/2007/11/06/the-community-technology-preview-ctp-of-windows-powershell-2-0.aspx

http://www.microsoft.com/downloads/details.aspx?displaylang=ko&FamilyID=845289ca-16cc-4c73-8934-dd46b5ed1d33

 

온라인 세미나

https://msevents.microsoft.com/CUI/WebCastRegistrationConfirmation.aspx?culture=ko-KR&RegistrationID=1296409903&Validate=false

소개

 http://qaos.com/article.php?sid=2532

파워셀 제공 명령어 설맹

http://qaos.com/article.php?sid=2533

 구문 설명.

 http://www.eldorado29.com/entry/Windows-PowerShell-%EA%B5%AC%EB%AC%B8

사용설명서

http://itka.kr/zbxe/?mid=oswindows&sort_index=readed_count&order_type=desc&page=3&document_srl=997

 

 

도움말.

get-help <cmdlet 이름> -detailed

get-help Get-Command

get-help get-command -detailed

get-help get-command -full

get-help get-command -examples

get-help get-command -parameter totalcount

 

 

 실행권한세팅

Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Unrestricted

 

s로 시작하는 프로세스보기

Get-Process [s]*

 PS HKLM:\> Get-Process | Group-Object processname

PS HKLM:\> Get-Process powershell | format-list modules, handles

 PS HKLM:\> Get-Process powershell | format-list *

 

 

PS HKLM:\> Get-Process | Sort-Object id

 PS HKLM:\> Get-Process | Sort-Object id -descending

 

레지스트리접근

CD hklm:  // HKEY_LOCAL_MACHINE          hkcu: // HKEY_CURRENT_USER

dir

cd SYSTEM

 

레지스트리 값가져오기 쓰기

PS HKLM:\> Get-ItemProperty SOFTWARE/Microsoft/windows/CurrentVersion/Run

Set-ItemProperty HKLM:/Example -name hello value 1

 

 텍스트 파일 가져오기.

Get-Content c:\a.txt

 

 

PS C:\> $text = "asdf ;lalksdfj"
PS C:\> Set-Content c:\a.txt $text
PS C:\> Get-Content c:\a.txt
asdf ;lalksdfj

 

XML

PS C:\> Get-Content c:\h.xml
<?xml version='1.0' encoding='euc-kr'?>
<jGame DOC_TYPE='APP'>
</jGame>

 

PS C:\> [xml]$hello = Get-Content c:\h.xml
PS C:\> echo $hello.jGame

DOC_TYPE
--------
APP

 

 

int, string 

 PS C:\> [int]$i="1"
PS C:\> $i +1
2

 

 PS C:\> [string]$s="1"
PS C:\> $s + 1
11

 

COM사용

 

 PS C:\> $ie = New-Object -comobject "internetexplorer.application"
PS C:\> $ie | Get-Member -MemberType method


WMI

 

PS C:\> Get-WmiObject win32_processor

PS C:\> Get-WmiObject win32_bios

PS C:\> Get-WmiObject win32_physicalmemory

 

 

 

  

 

get-service | get-member

 

. cmdlet 가져오는 개체 유형을 확인하려면 파이프라인 연산자(|) 사용하여 "get" 명령의 결과를 Get-Member 명령으로보내면 됩니다. 예를 들어 다음 명령은 Get-Service 명령에 의해 검색된 개체를 Get-Member 보냅니다.

 

 

 

PS R:\bin\ps1> get-service schedule | format-list -property *


Name                : Schedule
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
...       :

 

PS R:\bin\ps1> get-service schedule | format-table -property *

 

Name     CanPause CanShutd  CanStop DisplayN Dependen MachineN ServiceN Service Service  Status Service Site
         AndConti      own          ame      tService ame      ame      sDepend Handle             Type
              nue                            s                          edOn
----     -------- --------  ------- -------- -------- -------- -------- ------- -------  ------ ------- ----
Schedule    False    False    False Task ... {}       .        Schedule {RpcSs} Safe... Stopped ...cess

 

 

 

PS R:\bin\ps1> ipconfig | findstr "Address"

        IP Address. . . . . . . . . . . . : 192.168.2.215

 

별칭 만들기

set-alias gh get-help

set-alias np c:\windows\notepad.exe

remove-item alias:ls

function bootini {notepad c:\boot.ini}

 

 

Windows 프로그램 사용

PS> $env:path += ";newdirectory"

$env:path += ";C:\Program Files\Windows NT\Accessories"

get-psdrive

 

 

 

 

프로필 만들기

test-path $profile

new-item -path $profile -itemtype file -force

notepad $profile

 

 Out-* Cmdlet사용하여데이터리디렉션

Get-Process | Out-File -FilePath C:\temp\processlist.txt
 PS> Get-Process | Out-Host -Paging | Format-List
 PS> Get-Process | Format-List | Out-Host -Paging
PS> Get-Command | Out-Null
 Get-Command Get-Command | Out-Printer -Name "Microsoft Office Document Image Writer"

S> Get-Process | Out-File -FilePath C:\temp\processlist.txt -Encoding ASCII

 

 

PS> Get-Command | Out-File -FilePath c:\temp\output.txt

Get-Command | Out-File -FilePath c:\temp\output.txt -Width 2147483647

Get-Location

 Set-Location -Path C:\Windows -PassThru

 

최근 위치 저장  다시 불러오기(Push-Location  Pop-Location)

 Get-Location

 

스택에 현재 위치를 올려놓은 다음 Local Settings 폴더로 이동하려면 다음과 같이 입력하십시오.

Push-Location -Path "Local Settings"

 Pop-Location -PassThru

 

항목 실행(Invoke-Item)

 Invoke-Item C:\WINDOWS

 Invoke-Item C:\boot.ini

 

 

NET  COM 개체 만들기(New-Object)           

 New-Object -TypeName System.Diagnostics.EventLog

New-Object -TypeName System.Diagnostics.EventLog -ArgumentList Application

 $AppLog = New-Object -TypeName System.Diagnostics.EventLog -ArgumentList Application

 

New-Object -ComObject WScript.Shell

New-Object -ComObject WScript.Network

New-Object -ComObject Scripting.Dictionary

New-Object -ComObject Scripting.FileSystemObject

 

$ie = New-Object -ComObject InternetExplorer.Application

$ie.Visible = $true

 $ie.Navigate("http://www.microsoft.com/technet/scriptcenter/default.mspx")

$ie.Document.Body.InnerText

$ie.Document.Body | Get-Member

 $ie.Quit()

 $ie = $null

Remove-Variable ie

 

 

 액셀

$xl = New-Object -ComObject Excel.Application -Strict
$xl.Visible =  $true

 

 

컴퓨터의 IP 주소 표시

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property IPAddress

 

출처 : http://mech12.springnote.com/pages/1112272

'Power Shell' 카테고리의 다른 글

[ps] 폴더 존재여부 검사하기  (0) 2009.10.12
[ps] db 수동으로 붙이기  (0) 2009.10.07
[ps] 파워셀 기본문법  (0) 2009.10.07
[ps] 레지스트리 수정하기  (0) 2009.10.07
[ps] power shell 메뉴얼  (0) 2009.10.06
Posted by 동동(이재동)