在Powershell ISE中添加sharepoint的智能提示,Enable SharePoint PowerShell Commandlets in the PowerShell ISE

Powershell ISE在默认状态下有一个不好的地方就是不会显示关于SharePoint的一些智能提示,例如你写一个"get-"后面提示的选项里没有sp开头的一些对象。于是找了一下解决方案。

首先打开Powershell ISE, 把下面的代码拷贝到ISE中

 1 if (!(test-path $profile )) 
 2 { 
 3     new-item -type file -path $profile -force 
 4 } 
 5  
 6 
 7 $cmd = 'if((Get-PSSnapin | Where-Object {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) 
 8 { 
 9     Add-PSSnapIn "Microsoft.SharePoint.Powershell" 
10 }'
11 
12 out-file -FilePath $profile -InputObject $cmd -Append

运行以上代码,关闭ISE,然后在重新打开,你的ISE就会把关于SharePoint的snapin加载进来了。

posted @ 2015-12-23 10:14  杨崇伟  阅读(288)  评论(0编辑  收藏  举报
版权所有,转载请标明出处