![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Powershell 笔记
doudouyoutang
这个作者很懒,什么都没留下…
展开
-
catch 重命名的exception [System.Data.DuplicateNameException])
try{Enable-SPFeature-IdentityFEATURE>-Url SCOPE>-ErrorActionStop}catch[System.Management.Automation.ActionPreferenceStopException]{ if(!($_.Exception-is [System.原创 2012-11-23 18:21:13 · 788 阅读 · 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 · 775 阅读 · 0 评论 -
Windows powershell tips:Conditional Operators
复习下 -match,-like,-contains1. -match 用在 regular expression 去匹配 可以使用wildcardexample 1: 不是必须用在开头的匹配$guy = "Guy Thomas 1949"$guy - match “Th”# Result PS> True Example2: 一个错误的名字是不行的$guy =翻译 2013-05-15 12:03:18 · 520 阅读 · 0 评论 -
Where-Object
Where-Object的参数的是一个布尔表达式,$_代表过滤过程中经过管道的当前结果。另外Where-Object还有一个别名 “?” 更形象翻译 2013-05-28 12:44:59 · 991 阅读 · 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 · 547 阅读 · 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 · 581 阅读 · 0 评论 -
Using the Switch Statement
powershell 的 swith 语句强大的令人无法相信哈1. 最基本的语句$a = 5switch ($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 · 402 阅读 · 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 · 473 阅读 · 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 · 548 阅读 · 0 评论 -
An Introduction to PowerShell Modules
An Introduction to PowerShell Modules11 March 2011by Jonathan Medd<!--#pretty .codeblue {color:blue}#pretty .codebrown {color:brown}#pretty .codedarkred {color:darkred}#prett转载 2013-03-18 10:27:32 · 746 阅读 · 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 · 425 阅读 · 0 评论 -
在C#中调用Powershell Cmdlets
在C#中调用powershell的cmdlets是非常有用的方法,随着powershell的不断流行,微软针对powershell也会不断推出各个应用的管理模块,最流行的就是Exchage的管理模块,通过powershell的管理模块能完成所有的管理任务。如果在C#中直接调用这些管理模块的命令,那么就避免了深入了解各个应用的APIs接口,直接调用需要的命令就可以了,C#就可以完成前端的界面优化等其转载 2013-03-07 16:14:16 · 1138 阅读 · 0 评论 -
奇怪语法大锦记
PS> $first = "num1"PS> $second = "num2"PS> $third = "num3"PS> "$first:$second:$third"num3PS> "$first`:$second`:$third"num3PS> "$first::$second::$third"::num3PS> $colon = ":"PS> "$f原创 2012-11-23 15:17:49 · 299 阅读 · 0 评论