Search My Blog
Loading
Pages
Categories
- database (1)
- diary (9)
- english (3)
- free (8)
- grails (1)
- ipod (10)
- java (21)
- link (1)
- love (1)
- management (3)
- memo (9)
- movie (1)
- photography (15)
- powershell (1)
- productivity (2)
- reading (1)
- self-management (7)
- software (19)
- status (2)
- web-develop (1)
- webutils (4)
- wordpress (4)
Tags
500d ajax blog canon console d300s d3000 d5000 diary english firefox fish G10 game google reader grails grd info instapaper ipad iphone ipod java jedit love management MJ mysql nikon photo photography plugin productivity quartz search engine software spring tab taobao target touch up web wordpress zoundryArchives
-
Recent Comments
My Shares on Google Reader
Category Archives: productivity
How to run a powershell script from console
首先,要确保running policy已经被修改了。默认的Restricted是不能运行的。
然后,如果script file不在path下面,需要指定全路径。
如果全路径中间有空格,需要加双引号,然后在最前面加&。例子如下:
1: & "c:\My Scripts\test.ps1"
详情请参考http://technet.microsoft.com/en-us/library/ee176949.aspx
补充:
以上的是在powershell的console下运行。如果要在普通的console下,或者在bat文件里面运行,需要用下面的命令:
1: powershell.exe c:\test.ps1
如果要看到输出,在powershell.exe后面加上-noexit。在上面那个链接里面说,如果路径有空格,可以用命令:powershell.exe &’c:\My Scripts\test.ps1’来运行,但是我在1.0里面没有成功。不知道2.0是不是可以。本来准备把powershell的脚本也放到dropbox里面,然后又可以用lanuchy来运行,目前还是没做到。
读了一遍evernote的user guide