MSDN文章纠错Automating Microsoft SharePoint 2010 with Windows PowerShell 2.0 (book excerpt)

笔者经过实践, 发现文章Automating Microsoft SharePoint 2010 with Windows PowerShell 2.0 (book excerpt)中的Power Shell有错误.

第一个错误

=======================================

文章错误部分截图:

image

错误信息:

image

PS C:\Users\administrator.VSAT> New-SPManagedPath -RelativeURL "test" -WebApplic
ation "http://sps2010:8080/" -HostHeader -Explicit
New-SPManagedPath : Parameter set cannot be resolved using the specified named
parameters
.
At line:1 char:18
+ New-SPManagedPath <<<<  -RelativeURL "test" -WebApplication "http://sps2010:8
080/" -HostHeader -Explicit
    + CategoryInfo          : InvalidArgument: (:) [New-SPManagedPath], Parame
   terBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.SharePoint.Power
   Shell.SPCmdletNewManagedPath

解释:

New-SPManagedPath分为两种, 一种是带WebApplication参数的, 另一种是带HostHeader参数的.

image

这里的代码混淆了两种命令, 当然会运行出错.

解决方法

==================

命令中去掉PipeLine输入参数$webApp即可.

第二个错误

=======================================

文章中有代码如下:
$app = New-SPEnterpriseSearchServiceApplication `
-Name “Enterprise Search Hosting Service Application `
-DatabaseServer “spsql1” `
-DatabaseName “SharePoint_Hosting_Search” `
-ApplicationPool $pool `
-Partitioned

如果你运行它, 你会发现该命令报错.

原因是name参数后面缺了一个双引号".

这种文章都往MSDN上放, 太坑爹了.

建议MSDN站点提供评论功能, 这样有人发现了错误之后可以进行评论, 以帮助其他人不要再犯同样的错误, 耽误大家的宝贵时间.

参考资料

New-SPManagedPath
http://technet.microsoft.com/en-us/library/ff607693.aspx

原文地址:https://www.cnblogs.com/awpatp/p/2329160.html