[持续更新]一些有用的PowerShell收集
[2012-09-05]
可以使用下面的powershell命令来dump某web application中符合某条件的timerjob, 比如说, 下面的命令dump出端口在1007的web application的variation timer job.
PS> (get-spwebapplication http://servername).JobDefinitions | where {$_.DisplayName -match "variation"} | select DisplayName, IsDisabled, LastRunTime, Schedule | fl
使用下面的powershll来查看某个timer job的历史记录. 比如说, 下面的命令dump了端口在1007的web application中所有的variation timer jobs的历史记录.
PS> (get-spwebapplication http://servername).JobHistoryEntries | where {$_.JobDefinitionTitle -match "variation"}
下面的dump了"Variation create hierarchies job definition"的所有job history
PS> (get-spwebapplication http://servername).JobHistoryEntries | where {$_.JobDefinitionTitle -match "Variations Create Hierarchies Job Definition"}
使用下面的powershell来dump与某个page library相关联的所有的event receivers.
PS> (get-spweb http://servername/en).Lists["Pages"].EventReceivers | select Type,Class | fl
使用下面的powershell命令来dump出于某个站点相关联的所有的event receivers.
PS> (get-spweb http://servername/en).EventReceivers | select Type,Class | fl
使用下面的powershell命令来dump从SPFile对象中dump出二进制信息, 写到文件系统中去.
PS> $byteArr = ((get-spweb http://server).Lists["Master Page Gallery"].Items | where{$_.Name -match "VariationRootPageLayout.aspx" }).File.OpenBinary()
PS> [System.IO.File]::WriteAllBytes( "c:\VariationRootPageLayout.aspx", $byteArr)
当Microsoft SharePoint Foundation Administration是disabled的状态时, 可以使用下面的脚本来启动它. 感谢Eric Zhang提供此脚本.
$LocalServer =$null
$LocalServer = [Microsoft.SharePoint.Administration.SPServer]::Local;
$srvList = $LocalServer.ServiceInstancesforeach($srv in $srvList)
{
$a = $srv.Service.GetType().FullName
if ($a.Contains("Microsoft.SharePoint.Administration.SPAdministrationService"))
{
write-host $a ":" $srv.Status
$srv.Provision()
}
}
资料来源
============================
SharePoint Variations – The complete Guide – Part 14 – Troubleshooting