Pages

2 Nov 2016

Find Configuration Database Connection string in the Registry

SharePoint 2010:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDb

SharePoint 2013:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\Secure\ConfigDb

pic

22 Oct 2016

The Best Way to Develop SharePoint Client Side Applications

 

Please, read these articles by Andrew Koltyakov.

He explains in great detail how to properly develop client side solutions using tools like node, gulp, Visual Studio Code with SharePoint

21 Oct 2016

Add jQuery to any page in a console

var script = document.createElement("script"); 
script.type="text/javascript"; 
script.src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"; 
document.getElementsByTagName('head')[0].appendChild(script);

11 Oct 2016

Stefan Goßner: PSCONFIGUI.EXE vs PSCONFIG.EXE

Nice article: Why I prefer PSCONFIGUI.EXE over PSCONFIG.EXE by Stefan Goßner

In case you need to use PSCONFIG.EXE to automate some tasks you should use the following command:

PSConfig.exe -cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources -cmd services -install

7 Oct 2016

PowerShell script for monitoring SharePoint WFE's and SQL Server back-ends​​​​

#counters.txt contains a list of performance counters
#collect 
$fileName = "test{0:yyyyMMdd-HHmmss}.xml" -f (Get-Date) 
​get-counter -content (get-content counters.txt) -MaxSamples 2 -sampleinterval 5 |  Export-clixml $fileName

#save the results to the blg format. This will allow opening it with Performance Monitor
$fileName = "test{0:yyyyMMdd-HHmmss}.blg" -f (Get-Date) 
​get-counter -content (get-content counters.txt) -MaxSamples 2 -sampleinterval 5 |  Export-Counter $fileName
counters.txt contents:
\.NET CLR Memory(*)\% Time in GC 
\ASP.NET\Application Restarts 
\ASP.NET\Request Execution Time 
\ASP.NET\Requests Rejected 
\ASP.NET\Requests Queued 
\ASP.NET\Worker Process Restarts 
\ASP.NET\Request Wait Time 
\ASP.NET Applications(*)\Requests/Sec 
\LogicalDisk(*)\% Idle Time 
\Memory\Available MBytes 
\Memory\% Committed Bytes In Use 
\Memory\Page Faults/sec 
\Memory\Pages Input/sec 
\Memory\Page Reads/sec 
\Memory\Pages/sec 
\Memory\Pool Nonpaged Bytes 
\Network Interface(*)\Bytes Total/sec 
\Network Interface(*)\Packets/sec 
\Paging File(*)\% Usage 
\PhysicalDisk(*)\Current Disk Queue Length 
\PhysicalDisk(*)\% Disk Time 
\PhysicalDisk(*)\Disk Transfers/sec 
\PhysicalDisk(*)\Avg. Disk sec/Transfer 
\Process(*)\% Processor Time 
\Process(*)\Page Faults/sec 
\Process(*)\Page File Bytes Peak 
\Process(*)\Page File Bytes 
\Process(*)\Private Bytes 
\Process(*)\Virtual Bytes Peak 
\Process(*)\Virtual Bytes 
\Process(*)\Working Set Peak 
\Process(*)\Working Set 
\Processor(*)\% Processor Time 
\Processor(*)\Interrupts/sec 
\Redirector\Server Sessions Hung 
\Server\Work Item Shortages 
\System\Context Switches/sec 
\System\Processor Queue Length 
\Web Service(*)\Bytes Received/sec 
\Web Service(*)\Bytes Sent/sec 
\Web Service(*)\Total Connection Attempts (all instances) 
\Web Service(*)\Current Connections 
\Web Service(*)\Get Requests/sec

Show IIS Pool passwords in clear text

Windows 2012+ Solution:

Method #1


Add-WindowsFeature Web-WMI | Format-List
Get-CimInstance -Namespace root/MicrosoftIISv2 -ClassName IIsApplicationPoolSetting -Property Name, WAMUserName, WAMUserPass |
select Name, WAMUserName, WAMUserPass

 

Method #2


(Get-Item website).ProcessModel
(Get-Item website).ProcessModel.username
(Get-Item website).ProcessModel.password​

 

Windows 2008/R2 Solution


cd C:\Windows\system32\inetsrv
.\appcmd.exe list apppool /text:* ​

Add super user and super reader via PowerShell


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

####SET ACCOUNT NAMES (Replace Domain and UserName)
#SUPER USER ACCOUNT – Use your own Account (NB: NOT A SHAREPOINT ADMIN)
$sOrigUser= "domain\SP_SuperUser"
$sUserName = "SP_SuperUser"

#SUPER READER ACCOUNT – Use your own Account (NB: NOT A SHAREPOINT ADMIN)
$sOrigRead = "domain\SP_SuperRead"
$sReadName = "SP_SuperRead"

$apps = get-spwebapplication 
foreach ($app in $apps) {
   #DISPLAY THE URL IT IS BUSY WITH
   $app.Url
   if ($app.UseClaimsAuthentication -eq $true)
   {
    # IF CLAIMS THEN SET THE IDENTIFIER
    $sUser = "I:0#.w|" + $sOrigUser
    $sRead = "I:0#.w|" + $sOrigRead
   }
   else
   {
   # CLASSIC AUTH USED
     $sUser = $sOrigUser
     $sRead = $sOrigRead
   }
   
   # ADD THE SUPER USER ACC – FULL CONTROL (Required for writing the Cache)
   $policy = $app.Policies.Add($sUser, $sUserName)
   $policyRole = $app.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl) 
   $policy.PolicyRoleBindings.Add($policyRole)

   $app.Properties["portalsuperuseraccount"] = $sUser
   $app.Update()

   # ADD THE SUPER READER ACC – READ ONLY
   $policy = $app.Policies.Add($sRead, $sReadName)
   $policyRole = $app.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead) 
   $policy.PolicyRoleBindings.Add($policyRole)

   $app.Properties["portalsuperreaderaccount"] = $sRead
   $app.Update()
 }

Syntax highlighting. List of brushes

http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/

http://alexgorbatchev.com/SyntaxHighlighter/manual/demo/

C#
c-sharp, csharp
shBrushCSharp.js

CSS
css
shBrushCss.js

JavaScript
js, jscript, javascript
shBrushJScript.js

Plain Text
plain, text
shBrushPlain.js

PowerShell
ps, powershell
shBrushPowerShell.js

SQL
sql
shBrushSql.js

XML
xml, xhtml, xslt, html, xhtml
shBrushXml.js

Hide Attachments from specific SharePoint Group

 <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js' type="text/javascript">  
 </script>  
 <script type="text/javascript">  
   $(function() {  
     $.ajax({  
       url: "/_api/web/currentUser?$select=Groups/Title&$expand=Groups",  
       method: "GET",  
       headers: {  
         "Accept": "application/json; odata=verbose"  
       },  
       success: function(data) {  
         for (var k = 0; k < data.d.Groups.results.length; k++) {  
           var groupName = data.d.Groups.results[k].Title;  
           if (groupName == 'OECTA EXEC GL') {  
             $("[scriptclass='SharePointFileAttachmentCollection'], [scriptclass='SharePointFileAttachmentContainer']").hide();  
           }  
         }  
       },  
       error: function(data) {  
         console.log(data);  
       }  
     });  
   });  
 </script>