Wednesday, May 3, 2017

List of all web parts used on SharePoint 2013 pages using PowerShell

The following PowerShell will give text file for all web parts found on existing pages of SharePoint 2013.

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")

 function ListWebParts($web) {

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))

{

$webPublish = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

$pages = $webPublish.GetPublishingPages()

 

foreach($page in $pages)

{

$manager = $web.GetLimitedWebPartManager($page.Url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

$webCollection = $manager.WebParts

if($webCollection.Count -ne 0)

{

for($i =0;$i -lt $webCollection.Count; $i++)

{

$sw.writeline($web.url + "/" + $page.url + ";" + $webCollection[$i].GetType().Name + ";" +    $webCollection[$i].Title)

}

}

}

}

}

 

function LoadSPSite()

{

$siteURL = "http://www.sharepointsitepath/"

$site = New-Object Microsoft.SharePoint.SPSite($siteURL)

 

foreach($web in $site.allwebs)

{

write-output $web.Title

ListWebParts($web)

}

$site.Dispose()

}

 

$sw = [System.IO.StreamWriter] "C:\UsedControls\UsedControlDetails.txt"

$sw.writeline("Page URL;Web Part Type;Web Part Title")

LoadSPSite

$sw.close()

Thank you very much

          Fahadullah Karimi

         SharePoint Specialist


Error: The tool was unable to download Microsoft SQL Server 2012 Native Client. Please check your Internet connection and try again. SharePoint 2016 Prerequisite installer. Best Practice for disposing objects in SharePoint Development

Error: The tool was unable to download Microsoft SQL Server 2012 Native Client. Please check your Internet connection and try again. SharePoint 2016 Prerequisite installer.

 1.      On the server, open IE and go to www.microsoft.com.

2.      Pop up box will open that say "Content from website listed below is being blocked by Internet Explorer Enhanced Security Configuration".  Uncheck the box that says "Continue to prompt when website content is blocked"


Website Content Blocked

3.      Open IE settings (gear) > Internet Options > Security tab. Click on trusted sites. In the zones, Click sites and then type https://*.microsoft.com to the trusted websites and then click add. 

4.      Close IE

5.      Retry installing prerequisites.

Thank you very much

          Fahadullah Karimi

         SharePoint Specialist


How to get SharePoint 2013 Product key from current SharePoint 2013 Server List of all web parts used on SharePoint 2013 pages using PowerShell

Monday, May 1, 2017

How to get SharePoint 2013 Product key from current SharePoint 2013 Server

Open command prompt and run following script to retrieve your SharePoint product key from the SharePoint 2013 Server

function Get-SP-2013-ProductKey {

$map="BCDFGHJKMPQRTVWXY2346789"

$value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Office\15.0\Registration\{90150000-110D-0000-1000-0000000FF1CE}").digitalproductid[0x34..0x42]

$ProductKey = ""

for ($i = 24; $i -ge 0; $i--) {

$r = 0

for ($j = 14; $j -ge 0; $j--) {

$r = ($r * 256) -bxor $value[$j]

$value[$j] = [math]::Floor([double]($r/24))

$r = $r % 24

}

$ProductKey = $map[$r] + $ProductKey

if (($i % 5) -eq 0 -and $i -ne 0) {

$ProductKey = "-" + $ProductKey

}

}

$ProductKey

}

#Call function

Get-SP-2013-ProductKey


 

Thank you very much

          Fahadullah Karimi

         SharePoint Specialist


How to get current SharePoint farm Passphrase Error: The tool was unable to download Microsoft SQL Server 2012 Native Client. Please check your Internet connection and try again. SharePoint 2016 Prerequisite installer.