[英]Powershell error Add-PSSnapin “Microsoft.SharePoint.PowerShell”
I am getting an error when I run below command from sharepoint 2010 managment shell using admin rights. 当我使用管理员权限从sharepoint 2010管理shell运行以下命令时,出现错误。
Add-PSSnapin Microsoft.Sharepoint.Powershell
Add-PSSnapin : Cannot add Windows PowerShell snap-in Microsoft.Sharepoint.Power
shell because it is already added. Verify the name of the snap-in and try again
Check to see if module is already loaded: 检查模块是否已经加载:
if (Get-Module -ListAvailable -Name SomeModule) {
Write-Host "Module exists"
} else {
Write-Host "Module does not exist"
}
Source: How do I check if a powershell module is installed? 来源: 如何检查是否安装了Powershell模块?
UPDATED: 更新:
Try {
if((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null){
Add-PsSnapin Microsoft.SharePoint.PowerShell
}
}Catch{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.