About Me

SharePoint Architect with over 17 years of IT Experience in various roles as SharePoint Architect, Administrator, Technical Architect, IT Analyst, Application Developer, CRM Consultant, BI Developer, Microsoft Solution Architect in Client/Server, Web and Enterprise CRM Applications in E-Commerce, Financial, Healthcare, Insurance, Telecom, Outsourcing and Technology Services.
MCITP (Pro): Microsoft Certified IT Professional: SharePoint 2010 Administrator.
MCTS: Microsoft Certified Technology Specialist, SharePoint 2010 Configuration.

Thursday, August 7, 2014

Assign New Database Id




stsadm -o addcontentdb -url http://portal -databasename WSS_Content_DB -assignnewdatabaseid

content database shows zero site collections in it You probably need to update the site map in the config db.


$db = get-spcontentdatabase -Identity [insert guid of cdb here]
$db.RefreshSitesInConfigurationDatabase()


$app = get-spwebapplication identity url of the problem web app
$app.contentdatabses.count


$db = get-spwebapplication identity url of the webapplication that had the null entry 
$db.contentdatabses.delete(“guidOfProblemDb”)
$db = Get-SPDatabase -Identity "guidOfProblemDb"
$db.Delete()

Find WebPart usage in SharePoint Content Database

#Write Header to CSV File
$outputfile = "C:\PowerShellScripts\FindWebPart\VeritableFindWebPart.csv"

"Page URL,  Web Part Name" | out-file $outputfile

#Get all Webs
$WebApp = Get-SPWebApplication "http://dev.spsiteurl.com"
foreach($site in $WebApp.Sites)
{
#Iterate through webs
foreach ($web in $site.AllWebs)
{
#Get All Pages from site's Root into $AllPages Array
$AllPages = @($web.Files | Where-Object {$_.Name -match ".aspx"})

#Search All Folders for Pages
foreach ($folder in $web.Folders)
    {
       #Add the pages to $AllPages Array
       $AllPages += @($folder.Files | Where-Object {$_.Name -match ".aspx"})
    }
 
 #Iterate through all pages
 foreach($Page in $AllPages)
  {
     $webPartManager = $web.GetLimitedWebPartManager($Page.ServerRelativeUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
   
     # Array to Hold Closed Web Parts
                foreach ($webPart in $webPartManager.WebParts | Where-Object {$_ -like "*ViewClaims*"})
                {
                 $result = "$($web.site.Url)$($Page.ServerRelativeUrl), $($webpart.Title)"
                 Write-Host "Web Part Found at: "$result
                 $result | Out-File $outputfile  -Append
                }
         }
    }
 }

#Read more: http://www.sharepointdiary.com/2014/03/sharepoint-web-part-usage-report.html#ixzz313fhYrwl

Missing Features in SharePoint


Helpful Scripts, Queries to troubleshoot missing features in SharePoint Content.

select fullurl, description 
from WSS_Content_Sites1.dbo.Features f
join WSS_Content_clientsites.dbo.Webs w on f.WebId=w.Id
where FeatureId = '75a0fea7-c54f-46b9-86b1-2e103a8fedba'

fullurl                 description
sites/Intranet/policy                                                                                                     
sites/Intranet/IT                                                                                                           
(2 row(s) affected)

Find WebPart usage for WebPartTypeID
SELECT 
Webs.FullUrl As SiteUrl, 
Webs.Title 'Document/List Library Title', 
DirName + '/' + LeafName AS 'Document Name'
from AllDocs with (nolock)
INNER JOIN Webs On AllDocs.WebId = Webs.Id
INNER JOIN Sites ON Webs.SiteId = SItes.Id
inner join WebParts 
on AllDocs.Id = WebParts.tp_PageUrlID 
where 
WebParts.tp_WebPartTypeID = '8be2f2c4-7478-16ab-c942-bd8a1b0d7cef'

Find Feature details based on Setup Path
SELECT * FROM [WSS_Content_DB].[dbo].[AllDocs] a
with (nolock) WHERE a.[SetupPath] LIKE '%TSATypes%'



SQL Server scripts for routine database operations


Modify only Database name
ALTER DATABASE DB_OldName MODIFY NAME = DB_NewName
GO

Alter Logical Names (only)
ALTER DATABASE [DB_Name] MODIFY FILE (NAME=N'DB_DataFileNameOld', NEWNAME= N’DB_DataFileNameNew')
GO
ALTER DATABASE [DB_Name] MODIFY FILE (NAME=N'DB_LogFileNameOld_log', NEWNAME= N’DB_LogFileNameNew_log')
GO

Restore Database backup with new Database file names.
RESTORE DATABASE [DatabaseName] FROM DISK = 'P:\DatabasBackup.bak'
WITH
MOVE 'DB_DataLogicalName' TO 'P:\MSSQL.SHAREPOINT\Data\DatabaseName_NewName.mdb',
MOVE 'DB_LogLogicalName_Log' TO 'P:\MSSQL.SHAREPOINT\Log\DatabaseName_NewName_Log.ldf',

RECOVERY, REPLACE, STATS = 10;

Testing a Login to Database in PowerShell
When you run the following script you shouldn't get any error and script terminates gracefully.

$dataSource = "SQLDEV\SharePoint"
$user = "SharePointUser"$pwd = "Password"$database = "DatabaseName"$connectionString = "Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=False;"$connection = New-Object System.Data.SqlClient.SqlConnection$connection.ConnectionString = $connectionString$connection.Open()

Note: If you get an error as "A network-related error or instance-specific error occurred..." then you are connecting to an incorrect SQL Server instance or the ports may be blocking your communication.

     Run query after opening connection in above script.
     $query = "SELECT * FROM aspnet_Users"
     $command = $connection.CreateCommand()
     $command.CommandText = $query
     $result = $command.ExecuteReader()


Fix Database login during Database migrations
When you migrate a database with an existing login which you want to map your database user to, you could run the following. First parameter of ‘SharePointDBUser′ is the user in the database, the second one is login existing in SQL Server securities to be mapped to.
EXEC sp_change_users_login 'update_one','SharePointDBUser','SharePointDBUser'

Tuesday, September 10, 2013

Computer clock is showing incorrect time. Time is not in sync.


The computer did not resync because no time data was available (w32tm)


  • Type following command at command prompt:
    w32tm /resync /rediscover

    Sending resync command to local computer...The computer did not resync because no time data was available.


    To make sure that all domain members are using it, run:
    w32tm /config /syncfromflags:domhier /update
          After that run:
          net stop w32time
          net start w32time

Monday, September 9, 2013

SharePoint update (PU/CU) Installation Steps.


1. Download PU or CU

2. Stop Services before you Install update. ( Pay attnetion to squence )

NET STOP SPTimerV4
NET STOP OSearch15
NET STOP SPSearchHostController

3. Install

   Install First on Server hosting CA, then other App Servers and Web Servers.

4. Restart

   Restart First on Server hosting CA, then other App Servers and Web Servers.

5. Make sure Timer, Search, Host Controller are in stopped state.

NET STOP SPTimerV4
NET STOP OSearch15
NET STOP SPSearchHostController

6. Run Wizard

7. Start Services

NET START SPSearchHostController
NET START OSearch15
NET START SPTimerV4

8. Verify Build Number.

Wednesday, September 4, 2013

Windows Server 2012 Activation failed: Error Code 0x8007232B DNS name does not exist.




You may experience issues when trying to activate Windows (Bulk License) key in Virtual Machine.

It may be one of the cases that you are not connected to the host domain. Please check your network adapters. If you have connected the VM to a private DNS, then try to disable that adapter and add a New Adapter as NAT and try to connect to the Host DNS and its internet connection.

Have your windows key and run the following command.

    slmgr -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
    slmgr /ato

If above command doesn't work then try another option as below.

At command prompt

c:>Slui 3

this will open a GUI, where you can enter Windows 2012 KEY and choose option to activate.

This will probably work.