Skip Ribbon Commands
Skip to main content
Use SHIFT+ENTER to open the menu (new window).
  
  
  
Code
  
  
  
  
XSL
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
  
PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "http://servername/site"
$pageUrl = "default.aspx"
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$web =$site.OpenWeb()
$scope = [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared
$mgr = $web.GetLimitedWebPartManager($pageUrl, $scope)
$mgr.WebParts | Format-Table Title, WebBrowsableObject
  
C#
SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // do something
});
  
STSADM
stsadm -o setproperty -pn max-template-document-size -pv 40000000
  
XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>
Andy Burns
  
PowerShell
[Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet
http://hackerthedude.blogspot.com/2010/03/check-network-connectivity-with-power.html
  
JavaScript
<a onclick="GoToLink(this);return false;" href=....">
Dhiren
  
JavaScript
function FunctionName() {
    // Do something
}
_spBodyOnLoadFunctionNames.push("FunctionName");
  
PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
  
JavaScript
function OpenIwkidDialog(url, title)
{
  var options = SP.UI.$create_DialogOptions();
  options.url = url;
  options.title = title;
  SP.UI.ModalDialog.showModalDialog(options);
}
  
PowerShell
| Format-Table @{Expression={$_.Name};Label="Name";width=40}
Creating Custom Tables
  
XSL
<xsl:if test="ddwrt:IfNew(string(@Created))">
            <img src="/_layouts/1033/images/new.gif" alt="New" />
</xsl:if>
JoeD Blog
  
PowerShell
$farm = Get-SPFarm
$farm.Solutions | % { $_.SolutionFile.SaveAs("c:\temp\" + $_.Name); }
http://stefvanhooijdonk.com/2010/07/30/download-a-solution-from-your-farm-sp2100/
  
PowerShell
#     <add key="CustomVariable" value="custom value" />
$keyName = "CustomVariable";
$keyValue = "custom value";
$configMod1 = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$configMod1.Path = "/configuration/appSettings";
$configMod1.Name = [system.string]::format("add[@key=""{0}""]", $keyName);
$configMod1.Value = [system.string]::format("<add key=""{0}"" value=""{1}"" />", $keyName, $keyValue);
$configMod1.Sequence = 0
$configMod1.Owner = "SharePoint"
## SPWebConfigModificationType.EnsureChildNode -> 0
## SPWebConfigModificationType.EnsureAttribute -> 1
## SPWebConfigModificationType.EnsureSection -> 2
$configMod1.Type = 0

$webapp = Get-SPWebApplication http://WebApplciationUrl 
$webapp.WebConfigModifications.Add($configMod1)
$webapp.Update()
$webapp.Parent.ApplyWebConfigModifications()
http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/14/use-powershell-to-script-changes-to-the-sharepoint-web-config-file.aspx
  
PowerShell
$Voice = new-object -com SAPI.SpVoice
[void]$Voice.Speak("Test");
http://msdn.microsoft.com/en-us/library/ms723602(v=vs.85).aspx
  
PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
 
$envUrl = "http://servername"
 
$site = New-Object Microsoft.SharePoint.SPSite($envUrl)
$psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
$ctype = $psite.ContentTypes["Article Page"]
$layouts = $psite.GetPageLayouts($ctype, $true)
$layout = $layouts[0]
 
$web = $site.OpenWeb($webUrl);
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
 
$pages = $pweb.GetPublishingPages()
$page = $pages.Add("pagename.aspx", $layout)
 
$item = $page.ListItem
$item["Title"] = "My Page";
$item["Page Content"] = "<b>TEST</b>";
 
$item.Update()
 
$item.File.CheckIn("")
$item.File.Publish("")
  
PowerShell
[Security.Principal.WindowsIdentity]::GetCurrent().Name
  
SharePoint URL
?Contents=1
  
SharePoint URL
/_layouts/settings.aspx
  
SharePoint URL
/_layouts/savetmpl.aspx
  
SharePoint URL
/_layouts/sitemanager.aspx
  
SharePoint URL
/_layouts/viewlsts.aspx
  
PowerShell
Function Get-SPError([string]$id) { Get-SPLogEvent | ? { $_.Correlation -eq $id } | Out-GridView }
  
PowerShell
$SysEvent = Get-Eventlog -logname application -newest 2000
$SysError = $SysEvent |where {$_.entryType -match "Error"}
$SysError | sort eventid | `
Format-Table EventID, Source, TimeWritten, Message -wrap | out-file -filepath "C:\log.txt"
http://www.computerperformance.co.uk/powershell/powershell_eventlog.htm#PowerShell_Script_Example_3:_Errors_in_the_System_Log
  
Registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Reliability
Name:  ShutdownReasonUI, ShutdownReasonOn
Type:   REG_DWORD
Value:  1=enable;0=disable
http://support.microsoft.com/kb/555541
  
Registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList
 
New -> DWORD (32-bit) Value
Name:  match the account name
Value:  0 to hide, 1 to show the account
 
http://www.mydigitallife.info/how-to-create-hidden-user-account-hide-user-account-from-welcome-screen-in-windows/
  
PowerShell

$serviceAppName = "Word Automation Services"
$siteUrl = "http://localhost"
$sourceFile = "http://localhost/Shared%20Documents/SP2010%20Kerberos%20Guide.docx"
$destFile = "http://localhost/Shared%20Documents/SP2010%20Kerberos%20Guide.pdf"

$job  = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJob($serviceAppName)
$site = Get-SPSite $siteUrl
$job.UserToken = $site.UserToken
$job.settings.UpdateFields = $true
$job.Settings.OutputFormat = [Microsoft.Office.Word.Server.Conversions.SaveFormat]::PDF
$job.AddFile($sourceFile, $destFile)
$job.Start()

# Run the Timer Job
Get-SPTimerJob | ? { $_.Name -eq $serviceAppName } | % { $_.RunNow() }

# Check on the job

$complete = $false; $timeout = 10;

do {  $status = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJobStatus($serviceAppName, $job.JobId, $null)
      $status | ft
      if (($status.NotStarted -eq 0) -or ($timeout -eq 0)) { $complete = $true; break; }
      $timeout -= 1;
      sleep 10;
   } Until ($complete)

 

Developing with SharePoint 2010 Word Automation ServicesConvert Word documents to PDF in SharePoint Server 2010 using PowerShellRun Timer Jobs