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

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.

Wednesday, July 3, 2013

List Of useful Commands for Windows (XP)


Accessibility Controls - access.cpl
Add Hardware Wizard - hdwwiz.cpl
Add/Remove Programs - appwiz.cpl
Administrative Tools - control admintools
Automatic Updates - wuaucpl.cpl
Bluetooth Transfer Wizard - fsquirt
Calculator - calc
Certificate Manager - certmgr.msc
Character Map - charmap
Check Disk Utility - chkdsk
Clipboard Viewer - clipbrd
Command Prompt - cmd
Component Services - dcomcnfg
Computer Management - compmgmt.msc
Date and Time Properties - timedate.cpl
DDE Shares - ddeshare
Device Manager - devmgmt.msc
Direct X Control Panel (If Installed)* - directx.cpl
Direct X Troubleshooter - dxdiag
Disk Cleanup Utility - cleanmgr
Disk Defragment - dfrg.msc
Disk Management - diskmgmt.msc
Disk Partition Manager - diskpart
Display Properties - control desktop
Display Properties - desk.cpl
Display Properties (w/Appearance Tab Preselected) - control color
Dr. Watson System Troubleshooting Utility -
drwtsn32
Driver Verifier Utility - verifier
Event Viewer - eventvwr.msc
File Signature Verification Tool - sigverif
Findfast - findfast.cpl
Folders Properties - control folders
Fonts - control fonts
Fonts Folder - fonts
Free Cell Card Game - freecell
Game Controllers - joy.cpl
Group Policy Editor (XP Prof) - gpedit.msc
Hearts Card Game - mshearts
Iexpress Wizard - iexpress
Indexing Service - ciadv.msc
Internet Properties - inetcpl.cpl
IP Configuration (Display Connection Configuration) - ipconfig /all
IP Configuration (Display DNS Cache Contents) - ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents) - ipconfig /flushdns
IP Configuration (Release All Connections) - ipconfig /release
IP Configuration (Renew All Connections) - ipconfig /renew
IP Configuration (Refreshes DHCP & Re-Registers DNS) - ipconfig /registerdns
IP Configuration (Display DHCP Class ID) - ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID) - ipconfig /setclassid
ava Control Panel (If Installed) - jpicpl32.cpl
Java Control Panel (If Installed) - javaws
Keyboard Properties - control keyboard
Local Security Settings - secpol.msc
Local Users and Groups - lusrmgr.msc
Logs You Out Of Windows - logoff
Microsoft Chat - winchat
Minesweeper Game - winmine
Mouse Properties - control mouse
Mouse Properties - main.cpl
Network Connections - control netconnections
Network Connections - ncpa.cpl
Network Setup Wizard - netsetup.cpl
Notepad - notepad
Nview Desktop Manager (If Installed) - nvtuicpl.cpl
Object Packager - packager
ODBC Data Source Administrator - odbccp32.cpl
On Screen Keyboard - osk
Opens AC3 Filter (If Installed) - ac3filter.cpl
Password Properties - password.cpl
Performance Monitor - perfmon.msc
Performance Monitor - perfmon
Phone and Modem Options - telephon.cpl
Power Configuration - powercfg.cpl
Printers and Faxes - control printers
Printers Folder - printers
Private Character Editor - eudcedit
Quicktime (If Installed) - QuickTime.cpl
Regional Settings - intl.cpl
Registry Editor - regedit
Registry Editor - regedit32
Remote Desktop - mstsc
Removable Storage - ntmsmgr.msc
Removable Storage Operator Requests - ntmsoprq.msc
Resultant Set of Policy (XP Prof) - rsop.msc
Scanners and Cameras - sticpl.cpl
Scheduled Tasks - control schedtasks
Security Center - wscui.cpl
Services - services.msc
Shared Folders - fsmgmt.msc
Shuts Down Windows - shutdown
Sounds and Audio - mmsys.cpl
Spider Solitare Card Game - spider
SQL Client Configuration - cliconfg
System Configuration Editor - sysedit
System Configuration Utility - msconfig
System File Checker Utility (Scan Immediately) - sfc /scannow
System File Checker Utility (Scan Once At Next Boot) - sfc /scanonce
System File Checker Utility (Scan On Every Boot) - sfc /scanboot
System File Checker Utility (Return to Default Setting) - sfc /revert
System File Checker Utility (Purge File Cache) - sfc /purgecache
System File Checker Utility (Set Cache Size to size x) - sfc /cachesize=x
System Properties - sysdm.cpl
Task Manager - taskmgr
Telnet Client - telnet
User Account Management - nusrmgr.cpl
Utility Manager - utilman
Windows Firewall - firewall.cpl
Windows Magnifier - magnify
Windows Management Infrastructure - wmimgmt.msc
Windows System Security Tool - syskey
Windows Update Launches - wupdmgr
Windows XP Tour Wizard - tourstart
Wordpad - write