
Powershell 笔记
doudouyoutang
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
catch 重命名的exception [System.Data.DuplicateNameException])
try{ Enable-SPFeature -Identity FEATURE> -Url SCOPE> -ErrorAction Stop} catch [System.Management.Automation.ActionPreferenceStopException] { if( !($_.Exception -is [System.原创 2012-11-23 18:21:13 · 847 阅读 · 0 评论 -
What Is (and What Isn’t) in Our Array?
复习一下数组里面查找元素等一些基本的用法 比如定义了一个数组 $arrColors = "blue", "red", "green", "yellow", "white", "pink", "orange", "turquoise" 看看是否包含某个元素,一般都是做个循环去查找,但是powershell不用,直接用-contains 就可 $arrColors -contains "blac翻译 2013-05-16 11:06:13 · 811 阅读 · 0 评论 -
Windows powershell tips:Conditional Operators
复习下 -match,-like,-contains 1. -match 用在 regular expression 去匹配 可以使用wildcard example 1: 不是必须用在开头的匹配 $guy = "Guy Thomas 1949" $guy - match “Th” # Result PS> True Example2: 一个错误的名字是不行的 $guy =翻译 2013-05-15 12:03:18 · 566 阅读 · 0 评论 -
Where-Object
Where-Object的参数的是一个布尔表达式,$_代表过滤过程中经过管道的当前结果。另外Where-Object还有一个别名 “?” 更形象翻译 2013-05-28 12:44:59 · 1082 阅读 · 0 评论 -
Stady notes: Windows powershell tips -Even More Things You Can Do With Arrays
1.定义一个空的数组 $a = @() # 这样定义是不行的 [array]$a,奇怪的语法啊。 或者用。net framwork 里面的 $a = new-object System.collection.arrayList 2.定义一个固定类型的空数组 [int[]]$a = @() 3,定义一个已知元素的数组 $a = "one","two"转载 2013-05-13 10:59:22 · 594 阅读 · 0 评论 -
Stady notes: Windows powershell tips
1. Accessin values in an array 如:$a = 1,2,3,4,5,6,7,8 @访问下表 $a[2] 输出3 @可一次访问多个下标$a[1,3,5] 输出 2,4,6 或者a[1..3] 输出2,3,4, @访问最后一个可用$a[-1] 输出8 ===================翻译 2013-05-09 15:00:14 · 624 阅读 · 0 评论 -
Using the Switch Statement
powershell 的 swith 语句强大的令人无法相信哈 1. 最基本的语句 $a = 5 switch ($a) { 1 {"The color is red."} 2 {"The color is blue."} 3 {"The color is green."} 4 {"The co翻译 2013-05-16 17:28:55 · 446 阅读 · 0 评论 -
在一个session 里面加load dll问题
目前发现的在powershell 2.0 里,一个session 可以加同一个assembly 多次 在powershell 3.0 里,一个session 里面可以加载同一个assembly 一次,在重复加载就说这个assembly 文件找不到了 在网上找了下原因说:.NET assemblies can’t be unloaded from a session (it’s a .NET t原创 2013-03-27 16:21:21 · 520 阅读 · 0 评论 -
一个引号引起的血案
bat 不会用啊,引号不能乱用啊,哎 1. 如果设置的变量中有空格的话,最好当时不要加引号,用的时候在出来 set test=this is an applay 比如 robocopy "%test%"\Source\Common "%TARGET_CODE_FOLDER%\Source\Common" %CommonFile% 或者robocopy "%test%\Source\Commo原创 2013-04-03 17:32:31 · 599 阅读 · 0 评论 -
An Introduction to PowerShell Modules
An Introduction to PowerShell Modules 11 March 2011 by Jonathan Medd <!-- #pretty .codeblue {color:blue} #pretty .codebrown {color:brown} #pretty .codedarkred {color:darkred} #prett转载 2013-03-18 10:27:32 · 798 阅读 · 0 评论 -
check sharepoint server is standalone or farm mode
#----------------------------------------------------------------------------------- # # Check the SUT server installation mode. # # The sut server version. # Note:its value is gotton by callin原创 2013-03-01 16:43:39 · 459 阅读 · 0 评论 -
在C#中调用Powershell Cmdlets
在C#中调用powershell的cmdlets是非常有用的方法,随着powershell的不断流行,微软针对powershell也会不断推出各个应用的管理模块,最流行的就是Exchage的管理模块,通过powershell的管理模块能完成所有的管理任务。如果在C#中直接调用这些管理模块的命令,那么就避免了深入了解各个应用的APIs接口,直接调用需要的命令就可以了,C#就可以完成前端的界面优化等其转载 2013-03-07 16:14:16 · 1237 阅读 · 0 评论 -
奇怪语法大锦记
PS> $first = "num1" PS> $second = "num2" PS> $third = "num3" PS> "$first:$second:$third" num3 PS> "$first`:$second`:$third" num3 PS> "$first::$second::$third" ::num3 PS> $colon = ":" PS> "$f原创 2012-11-23 15:17:49 · 338 阅读 · 0 评论