2013년 1월 4일 금요일

레지스트리 조작 부팅시 start-up 프로그램 지정

################################################################## 
#  
# 부팅시 Install2를 자동으로 실행한다.
# 
################################################################# 

param
(
[string]$ParamOption
)

Function StartUpInstall
{
param([string]$ParamOption )
$RegStartUp= "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" 
if ($ParamOption -eq "/u")
{
Remove-ItemProperty $RegStartUp -Name Install
}
else 
{
Set-ItemProperty $RegStartUp -Name Install -Value c:\setup\install2.bat
}
}

StartUPInstall $ParamOption



Remove-ItemProperty $RegStartUp -Name Install = regkey를 지우는것

Set-ItemProperty $RegStartUp -Name Install -Value c:\setup\install2.bat  = regkey 수정이나 추가할때 쓰인다.


startup 출처: http://blog.scorpiotek.com/2008/12/31/how-to-create-startup-items-on-server-core/

Powershell 에서 XML Encoding 관련.


-encoding UTF8 이거 앞에 붙여야 에러가 안난다 꼭 인코딩을 신경쓰자


[xml] $XmlContent = Get-Content "c:\web.config" -encoding UTF8

echo $XmlContent.configuration.'system.serviceModel'.services.service.host.baseAddresses.add

echo $XmlContent.configuration.'system.serviceModel'.services.service.endpoint.address

이렇게 xml을 불러올올수 있고 노드를 찾아가면 된다. 만약 " . "이 있을경우 ' '로 묶으면 된다...

저렇게 되면 해당 노드값을 출력할수 있다.

수정및 저장은
$XmlContent.configuration.'system.serviceModel'.services.service.host.baseAddresses.add.baseAddress = "http://172.16.10.99:21000/MessageService.svc"
$XmlContent.configuration.'system.serviceModel'.services.service.endpoint.address = "net.tcp://172.16.10.99:20000/MessageService.svc"
$xmlContent.Save("c:\web.config")

머 이렇게 save를 하니까 잘되었다 하지만 인코딩이 좀 이상하다 확인해보아야할 부분이다.

powershll xml control에 대한 정보는 여기서 많이 얻을수 있다.
http://powershell.com/cs/blogs/tobias/archive/2009/02/02/xml-part-2-write-add-and-change-xml-data.aspx

출처 : http://hackss.tistory.com/entry/ps-xml-file-control-%ED%95%98%EA%B8%B0

Powershell 관련 Site

powershell simple menu

http://www.blkmtn.org/powershell-a-simple-menu

dictionary 사용

http://devcentral.f5.com/weblogs/Joe/archive/2008/12/29/powershell-abcs---g-is-for-generics.aspx

array 사용

http://blogs.sybase.com/powerbuilder/2009/07/powerscript-array-enhancement/

또 다른 hashtable 사용법(serer core 버전에서 위의 dictionary가 안되서 이걸썼다)

http://mow001.blogspot.com/2006/09/powershell-learn-about-hashtable_07.html

http://blogs.technet.com/b/heyscriptingguy/
http://blogs.technet.com/b/heyscriptingguy/rss.aspx

1) http://get-scripting.blogspot.com/  (이것은 iTunes에서 Podcast로 제공하기도 한다;get-scripting)
여기서 올린 자료를 RSS로 구독할 수 있다.

다음은 PowerShell 전문 블로그이다.
2) http://csharpening.net/  (여기는 PowerShell 3.0에 대한 내용을 다루고 있다.)

powershel l관련 community.
http://powershellcommunity.org



Learning Resources For Learning PowerShell
See below for sections on Commercial training, free online traning and books.
Commercial Training
CBT Nuggets: On The Job Training Series: Windows PowerShell
http://www.cbtnuggets.com/webapp/product?id=456

K Alliance: Windows PowerShell Training Courses
http://www.kalliance.com/microsoft-it/windows-powershell.htm

KOENIG: PowerShell for Windows Server 2008
http://www.koenig-solutions.com/training/Powershell_admin2008.asp?gclid=COy62pzC6JoCFQQ9ZgodHzZ2CA
Microsoft: Automating Administration with Windows PowerShell 2.0
Course 10325: Five days; Instructor led. Covers V2.
Official MOC
http://www.microsoft.com/learning/en/us/Course.aspx?ID=10325a
Microsoft: Automating Windows Server 2008 Administration with Windows PowerShell
Course 6434: Three days; Instructor-Led. Covers V1 only.
Official MOC
http://www.microsoft.com/learning/en/us/syllabi/6434afinal.mspx

Microsoft: Windows PowerShell for Administrators
Course 50025A: Three days; Instructor-Led. Covers V1 only.
Courseware Library
http://www.microsoft.com/learning/en/us/syllabi/50025afinal.mspx

PS Partnership
Custom PowerShell V1 and V2 Training on your site - world wide!
Contact: DoctorDNS@Gmail.Com
SAPIEN: Self-paced Training, Online Training, Classroom Training, and Private On-site Training
http://www.scriptinganswers.com/Training.asp

The SANS Institute PowerShell Training COurse
http://www.windowspowershelltraining.com/

TrainSiganl: Exchange Server 2007 PowerShell Course Outline
http://www.trainsignal.com/product_master_page_exchange_server_2007_powershell.aspx?ProductId=36

Verhoef Training: Windows PowerShell (UK)
http://www.verhoef-training.co.uk/outlines/WNPS.htm
Winstructor: Windows PowerShell Training
http://www.winstructor.com/products/Windows-PowerShell-Training.html

Free Online Training
ExclusivelyExchange provides excellent free online resources for learning more about PowerShell and Exchange.
Books
Mastering PowerShell - a free e-book by Dr Tobias Weltner
http://powershell.com/Mastering-PowerShell.pdf
Windows PowerShell in Action (1st Edition)
http://www.manning.com/payette/
Windows PowerShell in Action (2nd Edition)
http://www.manning.com/payette2/ (in progress currently - MEAP)
Windows PowerShell™ v2.0:TFM
http://www.sapienpress.com/powershell3.asp
The first edition is available for free at:
http://www.primaltools.com/downloads/communitytools/ under the PowerShell TFM V1 ebook section.
Windows PowerShell Pocket Reference:
http://oreilly.com/catalog/9780596521783/
Windows PowerShell(TM) 2.0 Administrator's Pocket Consultant:
http://www.microsoft.com/learning/en/us/Book.aspx?ID=12789&locale=en-us
PowerShell in Practice:
http://www.manning.com/siddaway/ (in progress currently - MEAP)
Effective Windows PowerShell:
http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!6930.entry
 (free ebook)

Windows PowerShell tips (Don Jones):
http://www.concentratedtech.com/upload/2/21powershelltips.pdf
www.concentratedtech.com/upload/2/21powershelltips.pdf
Topic Specific Books
Managing Active Directory with Windows PowerShell: TFM®:
http://www.sapienpress.com/ad.asp 
Managing VMWare Infrastructure with Windows PowerShell: TFM®:
http://www.sapienpress.com/vmware.aspMicrosoft SQL Server 2008 
Professional Windows PowerShell for Exchange Server 2007 Service =Pack 1:
http://www.wrox.com/WileyCDA/WroxTitle/Professional-Windows-PowerShell-for-Exchange-Server-2007-Service-Pack-1.productCd-0470226447.html
www.wrox.com/WileyCDA/WroxTitle/Professional-Windows-PowerShell-for-Exchange-Server-2007-Service-Pack-1.productCd-0470226447.html
Scripting SQL Management Objects in Windows PowerShell:
http://www.wrox.com/WileyCDA/WroxTitle/Scripting-SQL-Management-Objects-in-Windows-PowerShell.productCd-0470279354.html 
Microsoft PowerShell, VBScript & JScript Bible:
http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470386800,descCd-description.html
eu.wiley.com/WileyCDA/WileyTitle/productCd-0470386800,descCd-description.html