레이블이 powershell인 게시물을 표시합니다. 모든 게시물 표시
레이블이 powershell인 게시물을 표시합니다. 모든 게시물 표시

2013년 1월 8일 화요일

Powershell Shortcuts



(Alt) +(F7) Deletes the current command history
(PgUp) (PgDn) Display the first (PgUp) or last (PgDn) command you used in current session
(Enter) Send the entered lines to PowerShell for execution
(End) Moves the editing cursor to the end of the command line
(Del) Deletes the character to the right of the insertion point
(Esc) Deletes current command line
(F2) Moves in current command line to the next character corresponding to specified character
(F4) Deletes all characters to the right of the insertion point up to specified character
(F7) Displays last entered commands in a dialog box
(F8) Displays commands from command history beginning with the character that you already entered in the command line
(F9) Opens a dialog box in which you can enter the number of a command from your command history to return the command. (F7) displays numbers of commands in command history
(Left arrow) ,(Right arrow) Move one character to the left or right respectively
(Arrow up) (Arrow down) (F5) (F8) Repeat the last previously entered command
(Home) Moves editing cursor to beginning of command line
(Backspace) Deletes character to the left of the insertion point
(Ctrl) +(C) Cancels command execution
(Ctrl) +(End) Deletes all characters from current position to end of command line
(Ctrl) +(Arrow left) (Ctrl) +(Arrow right) Move insertion point one word to the left or right respectively
(Ctrl) +(Home) Deletes all characters of current position up to beginning of command line
(Tab) Automatically completes current entry, if possible

2013년 1월 4일 금요일

레지스트리읽기와 쓰기.


레지스트리 접근(레지스트리 내용은 디렉터리와 동일하게 접근)
HKEY_LOCAL_MACHINE : cd HKLM:
HKEY_CURRENT_USER : cd HKCU:

레스스트리 읽기, 쓰기
PS > Get-ItemProperty 키이름
PS > Set_ItemProperty 위치 -name 키이름 -value 키값

exe 실행하기


$xFilePath = "D:\nexusfile\"

$excute = $xFilePath + "x.exe"

&$excute

머 이렇게 하면 excute함수가 실행된다 & 붙여야되는것을 몰랐던것이다... ㅋㅋ


아 참고로 아귀먼트가 있으면

$excute = "notepad.exe"
$arg = "readme_ko.txt"

&$excute $arg

이런식으로 하면 된다... 바보 같이 

$excute = "noepad.exe readme_ko.txt" 이렇게 해서 실행하면 안된다.

레지스트리 조작 부팅시 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

2011년 5월 30일 월요일

[Powershell] 특정한 파일을 검색하여 그 파일 모두를 삭제하기

로컬 및 원격 컴퓨터의 특정한 파일을 검색하여 그 파일 모두를 삭제하고자 한다.
1) 특정한 폴더의 파일 확인하기
Get-ChildItem d:\test\*
2) 특정한 폴더를 확인한 후 모두 삭제하기
Get-ChildItem d:\test\* | ForEach ($_) {Remove-Item $_.fullname}
3) 폴더의 특정한 파일을 포함한 것만 확인하기(확장자 txt)
Get-ChildItem d:\test\* -Include *.txt
4) 폴더의 특정한 파일을 포함한 것을 확인하되, 특정한 이름(파일 이름이 '업무'로 시작하는 것)이 들어 간 것은 제외하기
Get-ChildItem d:\test\* -Include *.txt -Exclude 업무*.txt
5) 하위 폴더까지 모두 확인하기
Get-ChildItem d:\* -Include *.txt -Recurse
6) 하위 폴더까지 모두 확인한 후 몽땅 삭제하기 (C:\ 아래에 있는 모든 임시 파일(*.tmp))
Get-ChildItem c:\* -Include *.tmp -Recurse | ForEach ($_) {Remove-Item $_.fullname}
7) 원격 컴퓨터의 파일(C:\Test\*)을 확인한 후 몽땅 지우기

원격 컴퓨터로 접속하려면 사전에 원격 컴퓨터에서 접속 허용을 해두어야 한다. Enable-PSRemoting -Force

또는 Group Policy를 사용하여 PS1 스크립트 파일을 적용하도록 해두어야 한다.

Invoke-Command -Computername R2-C -ScriptBlock {Get-ChildItem C:\test\* -Recurse} : 확인만 하기

Invoke-Command -Computername R2-C -ScriptBlock {Get-ChildItem C:\test\* -Recurse| ForEach ($_) {Remove-Item $_.fullname}} : 확인하고 지우기

8) 원격 컴퓨터의 파일 중에서 확장자가 mp3 파일만 확인한 후 모두 삭제하기 (음악 파일 및 동영상 파일 확인)

Invoke-Command -Computername R2-C -ScriptBlock {Get-ChildItem C:\test\* -Include *.mp3 -Recurse} : 확인만 하기

Invoke-Command -Computername R2-C -ScriptBlock {Get-ChildItem C:\test\* -Include *.mp3 -Recurse| ForEach ($_) {Remove-Item $_.fullname}} : 확인하고 지우기

9) 원격 컴퓨터가 많이 있을 때 파일 확인하고 삭제하기

이럴 때는 원격 컴퓨터의 이름을 파일로 만들어 둔다.( c:\computers.txt)

icm -computername (Get-Content c:\computers.txt) -ScriptBlock {Get-ChildItem C:\test\* -Include *.mp3 -Recurse} : 확인만 하기

icm -computername (Get-Content c:\computers.txt) -ScriptBlock {Get-ChildItem C:\test\* -Include *.mp3 -Recurse | ForEach ($_) {Remove-Item $_.fullname}} : 확인하고 지우기

10) 명령 내용이 너무 길기 때문에 위의 명령어를 파워셀 스크립트(.ps1) 파일로 만든 후, 이 파일을 불러 들어 실행하여 삭제하기

스크립트 파일 이름: DeleteMP3.ps1

스크립트 파일 내용: Get-ChildItem C:\test\* -Include *.mp3 -Recurse | ForEach ($_) {Remove-Item $_.fullname}

icm -FilePath c:\DeleteMP3.ps1 -Computername (Get-Content c:\computers.txt)

이렇게 하면 회사에 있는 모든 컴퓨터를 검색하여 mp3 파일을 몽땅 지울 수 있다.

** 주의 사항: ps1 스크립트 파일을 실행하려면 Set-ExecutionPolicy RemoteSigned 로 사전에 설정해두어야 한다.

11) 로컬 컴퓨터의 임시 파일(*.tmp)을 확인하고 지우고자 하면

Get-ChildItem C:\* -Include *.tmp -Recurse : 임시 파일 확인하기

Get-ChildItem C:\* -Include *.tmp -Recurse | | ForEach ($_) {Remove-Item $_.fullname} : 임시 파일 확인한 후 지우기

참고: http://blogs.technet.com/b/heyscriptingguy/archive/2006/10/23/how-can-i-use-windows-powershell-to-delete-all-the-tmp-files-on-a-drive.aspx

2010년 12월 1일 수요일

[Powershell] 버전 정보를 읽어서 출력

 

파일에서 특정문자열을 검색해서  특정문자 앞에 있는 문자를 출력.

$version1=(Get-Command $source_file).FileversionInfo.FileVersion
$version2=$version1.split(" ")[3]

“ “  특정문자열검색


[] 몇번째값

인수1 : 버전읽을 파일 경로

인수2 : 저정할 파일경로



2개의 인수값을 읽어 version.txt 파일로 저장.



2, 0 , 0, 4 일경우 4를 version.txt파일에 저장함.



$source_file = $args[0]
$ver_dir= $args[1]
$verinfo="Version.txt"
$version1=(Get-Command $source_file).FileversionInfo.FileVersion
$version2=$version1.split(" ")[3]
set-content -path $ver_dir\$verinfo -value $version2

2010년 9월 27일 월요일

asterisk 를 사용하려고 할때

asterisk 검색할때

“\* “이문자를 쓰면됨.

$rc_file = get-Content -path D:\log2.txt
$rc_length = $rc_file.Length 
for ($i =0 ; $i -lt $rc_length; $i++)
{
    if ($rc_file[$i] -match "\*\*") {$message+= $rc_file[$i] +"`n"}
} 
set-Content -path D:\SRC\BuildTools\Rlog.txt $message


Hey, Scripting Guy! How Can I Use Windows PowerShell to Replace Characters in a Text File? - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs

2010년 9월 13일 월요일

파워 쉘 로 자동화하기 (Windows Automation Snapin for Powershell)

WASP(Windows Automation Snapin for Powershell) http://wasp.codeplex.com/

윈도우를 선택, 활성화, 창 크기 변경, 창 닫기, Keyboard,Mouse Action 등을 할 수 있는 PowerShell 자동화 Snapin

Autohot Key 와 비슷한 기능들을 이용 가능할 것 같다.

사용 가능한 명령어들은 아래와 같다.

•Select-Window - pick windows by process name or window caption (with wildcard support)

•Select-ChildWindow - pick all owned windows of another window (eg: dialogs, tool windows)

•Select-Control - pick controls (children) of a specific window, by class and/or name and/or index (with wildcard support) -- NOTE: the "Window" can be specified as "-Window 0" to get all parentless windows, which includes windows, dialogs, tooltips, etc... With -Window 0 this returns a true superset of the Select-Window output.

•Send-Click - send mouse clicks (any button, with any modifier keys) •Send-Keys - Windows.Forms.SendKeys lets you send keys ... try this: Select-Window notepad | Send-Keys "%(ea)Testing{Enter}{F5}" (and for extra fun, try it with multiple notepad windows open).

•Set-WindowActive - yeah, just activates the window

•Set-WindowPosition - set any one of (or all of) top, left, width, height on a window ... or maximize/minimize/restore

•Get-WindowPosition - get the position (kind-of redundant, actually, since the Window object has it's position as a property)

•Remove-Window - closes the specified window

WASP 1.3 RC 버전이 이글을 쓸때의 신버전이고(20100913) http://wasp.codeplex.com/releases/view/22118

설치는 압축을 해제하면 .아래 3개의 파일이 실행된다.

Install.ps1
UnInstall.ps1
WASP.dll

PowerShell 을 실행 후  Install.ps1 을 실행하면  2.0이 설치되어있다고 PSSnapin을 이용해 Import-Module 을 하거나 -Force를 이용해서 하라고 한다.

PS C:\WASP> .\Install.ps1
You're running PowerShell 2.0, so you don't need to Install this as a PSSnapin, you can use Import-Module (or Add-Module
in CTP2) to load it.  If you still want to install it as a PSSnapin, re-run this script with -Force

-Force 명령을 실행하면 아래와 같이 설치가 진행 된다.

PS C:\WASP> .\Install.ps1 -force
You're running PowerShell 2.0, so you don't need to Install this as a PSSnapin, you can use Import-Module (or Add-Module
in CTP2) to load it.  If you still want to install it as a PSSnapin, re-run this script with -Force
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4927
Copyright (c) Microsoft Corporation. All rights reserved.

트랜잭트 설치를 실행하고 있습니다.

설치의 Install 단계를 시작하고 있습니다.
C:\Users\kwang\Desktop\WASP\WASP\WASP.dll 어셈블리의 진행 상황을 보려면 로그 파일 내용을 검토하십시오.
파일은 C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog 위치에 있습니다.
어셈블리 'C:\Users\kwang\Desktop\WASP\WASP\WASP.dll'을(를) 설치하고 있습니다.
영향을 받는 매개 변수:
   assemblypath = C:\Users\kwang\Desktop\WASP\WASP\WASP.dll
   logfile = C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog
   logtoconsole =

Install 단계는 완료되었으며 Commit 단계를 시작하고 있습니다.
C:\Users\kwang\Desktop\WASP\WASP\WASP.dll 어셈블리의 진행 상황을 보려면 로그 파일 내용을 검토하십시오.
파일은 C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog 위치에 있습니다.
어셈블리 'C:\Users\kwang\Desktop\WASP\WASP\WASP.dll'을(를) 커밋하고 있습니다.
영향을 받는 매개 변수:
   assemblypath = C:\Users\kwang\Desktop\WASP\WASP\WASP.dll
   logfile = C:\Users\kwang\Desktop\WASP\WASP\WASP.InstallLog
   logtoconsole =

Commit 단계가 완료되었습니다.

트랜잭트 설치가 완료되었습니다.

CommandType     Name                                                Definition
-----------     ----                                                ----------
Cmdlet          Get-WindowPosition                                  Get-WindowPosition [-Window] <WindowHandle[]> [-...
Cmdlet          Remove-Window                                       Remove-Window [-Window] <WindowHandle[]> [-Passt...
Cmdlet          Select-ChildWindow                                  Select-ChildWindow [-Window] <WindowHandle[]> [-...
Cmdlet          Select-Control                                      Select-Control [[-Index] <Int32>] -Window <Windo...
Cmdlet          Select-Window                                       Select-Window [[-ProcessName] <String[]>] [-Tool...
Cmdlet          Send-Click                                          Send-Click [[-Left] <Int32>] [[-Top] <Int32>] [[...
Cmdlet          Send-Keys                                           Send-Keys [-Keys] <String> [-Window] <WindowHand...
Cmdlet          Set-WindowActive                                    Set-WindowActive [-Window] <WindowHandle[]> [-Pa...
Cmdlet          Set-WindowPosition                                  Set-WindowPosition [[-Left] <Int32>] [[-Top] <In...
To load the Windows Automation Snapin in the future, you need to run:
Add-PSSnapin WASP

You can also add that line to your Profile script to load it automatically.

Sample Demo

## Open a couple windows(윈도우를 두개 실행)
notepad.exe
explorer.exe

## list the windows( 윈도우 리스트를 출력)
Select-Window | ft –auto

## Activate Notepad(노트패드를 활성화)
Select-Window notepad* | Set-WindowActive

## Close Explorer( 탐색기 종료)
Select-Window explorer | Select -First 1 | Remove-WIndow

## Run a few more copies of notepad(노트패드를 여러개 실행)
notepad; notepad; notepad; notepad;

## Move them around so we can see them all ... (Note the use of foreach with the incrementation)위치 변경
$i = 1;$t = 100; Select-Window notepad | ForEach { Set-WindowPosition -X 20 -Y (($i++)*$t) -Window $_ }

## Put some text into them(텍스트를 입력)

Select-Window notepad | Send-Keys "Test Send-Keys !!!"

#### Close the first notepad window by pressing ALT+F4, and pressing Alt+N
## In this case, you don't have to worry about shifting focus to the popup because it's modal
## THE PROBLEM with sending keys like that is:
## if there is no confirmation dialog because the file is unchanged, the Alt+N still gets sent

Select-Window notepad | Select -First 1 | Send-Keys "%{F4}"

## Close the next notepad window ...
## By asking nicely (Remove-Window) and then hitting "n" for "Don't Save"
## If there are no popups, Select-ChldWindow returns nothing, and that's the end of it

## Close the next notepad window the hard way
## Just to show off that our "Window" objects have a ProcessID and can be piped to kill

Select-Window notepad | Select -First 1 | kill

## A different way to confirm Don't Save (use CLICK instead of keyboard)
## Notice how I dive in through several layers of Select-Control to find the button?
## This can only work experimentally:
## use SPY++, or run the line repeatedly, adding "|Select-Control" until you see the one you want

Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-childwindow | select-control| select-control| select-control -title "Do&n't Save" | Send-Click

## But now we have the new -Recurse parameter, so it's easy. Just find the window you want and ...

Select-Window notepad | Select -First 1 | Remove-Window -Passthru | Select-childwindow | select-control -title "Do&n't Save" -recurse | Send-Click

2010년 9월 3일 금요일

PS1 파일 실행할수 있도록 하기

PS1 파일 실행할수 있도록 하기
Set-ExecutionPolicy Remotesigned

공유폴더에 위차한 서명되지 않은 파워쉘 실행
Set-ExecutionPolicy Unrestricted

2010년 9월 2일 목요일

Using PowerShell to update AsssemblyFileVersions

Asssemblyfile 버전을 변경해주는 Powershell 스크립트

SetVersion.ps1

# SetVersion.ps1
#
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
#
# usage:  
#  from cmd.exe: 
#     powershell.exe SetVersion.ps1  2.8.3.0
# 
#  from powershell.exe prompt: 
#     .\SetVersion.ps1  2.8.3.0
#
# last saved Time-stamp: <Wednesday, April 23, 2008  11:46:40  (by dinoch)>
#
function Usage
{
  echo "Usage: ";
  echo "  from cmd.exe: ";
  echo "     powershell.exe SetVersion.ps1  2.8.3.0";
  echo " ";
  echo "  from powershell.exe prompt: ";
  echo "     .\SetVersion.ps1  2.8.3.0";
  echo " ";
}
function Update-SourceVersion
{
  Param ([string]$Version)
  $NewVersion = 'AssemblyVersion("' + $Version + '")';
  $NewFileVersion = 'AssemblyFileVersion("' + $Version + '")';
  foreach ($o in $input) 
  {
    Write-output $o.FullName
    $TmpFile = $o.FullName + ".tmp"
     get-content $o.FullName | 
        %{$_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
        %{$_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion }  > $TmpFile
     move-item $TmpFile $o.FullName -force
  }
}
function Update-AllAssemblyInfoFiles ( $version )
{
  foreach ($file in "AssemblyInfo.cs", "AssemblyInfo.vb" ) 
  {
    get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ;
  }
}
# validate arguments 
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^[0-9]+(\.[0-9]+){1,3}$");
if ($r.Success)
{
  Update-AllAssemblyInfoFiles $args[0];
}
else
{
  echo " ";
  echo "Bad Input!"
  echo " ";
  Usage ;
}


Building SharePoint Projects with PowerShell and MSBuild - SharePoint Depth Wiki - SharePoint Depth



Powershell script to batch-update AssemblyInfo.cs with new Version - All About Interop - Site Home - MSDN Blogs