使用PowerShell检索SharePoint中部署解决方案的详细信息
-
22-09-2019 - |
题
我需要使用powerShell脚本(v2.0)中中央管理>“操作管理”(又称解决方案商店)中显示的所有已部署的SharePoint解决方案的详细信息。谁能提供有关如何通过SharePoint API从SharePoint解决方案商店检索此信息的任何指导?
谢谢,魔术师。
解决方案
这实际上很容易做到。您可以连接到SP农场,并要求get_solutions。
这是一个示例:
# Connect to the Farm
$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()
# What Solution are we looking for?
$solution = "sharepointlearningkit.wsp";
# Get the solutions
$currentSolution = $SPfarm.get_Solutions() | Where-Object { $_.DisplayName -eq $solution; }
$currentSolution;
其他提示
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
function Get-LocalSPFarm()
{
return [Microsoft.SharePoint.Administration.SPFarm]::Local
}
function List-Solutions()
{
$farm = Get-LocalSPFarm
foreach ($solution in $farm.Solutions)
{
Write-Host($solution.DisplayName)
# Get-Member -InputObject $solution -MemberType property
}
}
全部归功于米切尔!
你可以打电话 stsadm.exe -o enumsolutions
从您的PowerShell脚本。它返回XML数据,您可以轻松地转换为 [xml]
数据类型并从中查看您需要的任何内容。
(STSADM生活在 c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin
)
输出由类似于此的陈述组成
<Solution Name="yoursolution.wsp">
<Id>ab693dcd-6483-45ad-abba-9c996c67b6e0</Id>
<File>yoursolution.wsp</File>
<Deployed>TRUE</Deployed>
<WebApplicationSpecific>TRUE</WebApplicationSpecific>
<ContainsGlobalAssembly>TRUE</ContainsGlobalAssembly>
<ContainsCodeAccessSecurityPolicy>FALSE</ContainsCodeAccessSecurityPolicy>
<Deployment WebApplication="http://devserver/" />
<LastOperationResult>DeploymentSucceeded</LastOperationResult>
<LastOperationTime>10/26/2009 9:06 AM</LastOperationTime>
</Solution>
这是我用来撤回解决方案信息的三个PowerShell CMDLET。与上面的那些相比,我的很简单,但我想我还是会提交它们:)
在SP2010管理壳中
列出所有解决方案。返回解决方案名称,ID和部署状态
求解
列出特定解决方案的所有属性
get -spsolution -nidentity |选择 *
将所有解决方案,属性和输出列出要读取的文件:)
get-spsolution |选择 * |外文件C: solutions.txt
不隶属于 StackOverflow