- Let your computer can run powershell script : Set-ExecutionPolicy RemoteSigned
- 將使用者需要互動輸入的選項,自動帶入指令中 :
因在build software時,會進入cygwin的環境中,並需輸入選項去build, 為將整個動作自動化 - 單一次選項時 : sunny || .\login.bat ==> 執行login.bat時,會等待user輸入其名字再做login, 此時利用pipeline, powershell 會自動將 'sunny' input
- 需多次輸入時 :
ps >@' [enter]
>> input1 [enter]
>> input2 [enter]
>> '@ | command - refer to : http://powershell.com/cs/blogs/tips/archive/2009/07/15/feeding-input-into-native-commands.aspx
- Execute powershell script (.ps1 file) as a command (可應用於task scheduler中) :
powershell.exe -command "&{d:\ps\sample.ps1 arg1 arg2}" - Print all System variable
Get-ChildItem -Path Variable: ` | Add-Member ` -Name Type ` -MemberType ScriptProperty ` -Value { $this.GetType().FullName } ` -PassThru ` | Add-Member ` -Name DisplayValue ` -MemberType ScriptProperty ` -Value { (Get-Variable -Name $this.Name -Scope 1 -ValueOnly | Format-List -Property * | Out-String).Trim("`r`n") } ` -PassThru ` | Sort-Object -Property Name ` | Format-List -Property Name,Type,Description,Value,DisplayValue,Options ` | Out-Host -Paging
2010年9月21日 星期二
Powershell - some tip
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言