Thursday, October 15, 2015

Converting Word or Excel File To PDF Without Losing Hyperlinks

One of my user experiencing issues with opening hyperlinks from PDF document. the hyperlinks are working in word and excel documents but when converted to PDF then the hyperlinks are displayed but not clickable.

You can covert the word or excel document to PDF including embedded links by doing the following steps,

  1. Go to File→Save As and choose the destination where you want to save your file. Name your file.
  2. Under File Name, you’ll see a drop down menu labelled Save as Type, select PDF.
  3. Under PDF Options (near the bottom), unselect ISO 19005-1 Compliant (PDF/A). Forcing compliance is what disables hyperlinks. By unchecking the box, your links will become clickable. Click Okay.




Thursday, October 8, 2015

Image map with SharePoint designer 2010


A picture with hot spots is called an image map, hot spot is area on an object containing a hyperlink. The picture can contain multiple hot spots.

In SharePoint Designer 2010, all you need to do is open page and select the picture (that you want to add an image map to).  At the top of the Ribbon, click on Picture Tools –> Format –> Hotspot, and then add in whatever hotspots you want (after adding the hotspot, you will be prompted for the URL you are linking to).


Note: This will not work on Publishing Pages, as SharePoint Designer will only let you edit the layout of publishing pages, and not the content.

Tuesday, September 22, 2015

PowerShell script to get all the documents with the last modified date in a SharePoint site

To find out all the documents with the last modified date using PowerShell Script

In Site level,

    If you want to find out in a specific site , please use the following script. Provide the site URL where heighted.

Get-SPWeb http://yoursite[site Url] | Select -ExpandProperty Lists | Where {-not $_.hidden -and $_.GetType().Name -eq "SPDocumentLibrary" } | Select -ExpandProperty Items | Select Name, { $_["Modified"] } | Out-File C:\filename.txt

In Site Collection level,

    If you want to find out in entire site collection, please use the following script. Provide the site collection URL where heighted.

Get-SPSite http://yoursite[site collection url] | Select -ExpandProperty AllWebs | Select -ExpandProperty Lists | Where {-not $_.hidden -and $_.GetType().Name -eq "SPDocumentLibrary" } | Select -ExpandProperty Items | Select Name, { $_["Modified"] } | Out-File C:\filename.txt

Powershell script to check and count number of site collections in a web application


This PowerShell script will get the count of all site collections in a web application

param($Site,$FilePath)
 
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
 
function GenerateAllSitecollectionsCountInWebapplication ($url)
{
    write-host "Extracting the count of site collections in web application....." -foregroundcolor black
    try
      {
         $Site=Get-SPSite $url      
         $spWebApp = $Site.WebApplication
         write-host Total count in $url is   $Site.WebApplication.Sites.Count -foregroundcolor red
      }
   catch
      {
          write-host "Unable to Extract Sitecollection count .."  -foregroundcolor red
          break
      }
}
GenerateAllSitecollectionsCountInWebapplication -Url "Web application URL"

Friday, September 18, 2015

Powershell Script to get all the user permissions report for a SharePoint Site

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function GetUserAccessReport($WebAppURL,$FileUrl)
{
 #Get All Site Collections of the WebApp
 $SiteCollections = Get-SPSite -WebApplication $WebAppURL -Limit All

#Write CSV- TAB Separated File) Header
"URL `t Site/List `t Title `t PermissionType `t Permissions  `t LoginName" | out-file $FileUrl


#Check Web Application Policies
$WebApp= Get-SPWebApplication $WebAppURL

foreach ($Policy in $WebApp.Policies)
  {
#Check if the search users is member of the group
#if($Policy.UserName -eq $SearchUser)
 # {
#Write-Host $Policy.UserName
$PolicyRoles=@()
foreach($Role in $Policy.PolicyRoleBindings)
{
$PolicyRoles+= $Role.Name +";"
}
#Write-Host "Permissions: " $PolicyRoles

"$($AdminWebApp.URL) `t Web Application `t $($AdminSite.Title)`t  Web Application Policy `t $($PolicyRoles) `t $($Policy.UserName)" | Out-File $FileUrl -Append
#}
  }

  #Loop through all site collections
   foreach($Site in $SiteCollections)
    {
 #Check Whether the Search User is a Site Collection Administrator
 foreach($SiteCollAdmin in $Site.RootWeb.SiteAdministrators)
      {
"$($Site.RootWeb.Url) `t Site `t $($Site.RootWeb.Title)`t Site Collection Administrator `t Site Collection Administrator `t $($SiteCollAdmin.LoginName)" | Out-File $FileUrl -Append

}

  #Loop throuh all Sub Sites
       foreach($Web in $Site.AllWebs)
       {
if($Web.HasUniqueRoleAssignments -eq $True)
            {
       #Get all the users granted permissions to the list
           foreach($WebRoleAssignment in $Web.RoleAssignments )
               {
                 #Is it a User Account?
if($WebRoleAssignment.Member.userlogin)  
{
  #Get the Permissions assigned to user
$WebUserPermissions=@()
   foreach ($RoleDefinition  in $WebRoleAssignment.RoleDefinitionBindings)
  {
                       $WebUserPermissions += $RoleDefinition.Name +";"
                      }
#write-host "with these permissions: " $WebUserPermissions
#Send the Data to Log file
"$($Web.Url) `t Site `t $($Web.Title)`t Direct Permission `t $($WebUserPermissions)  `t $($WebRoleAssignment.Member.LoginName)" | Out-File $FileUrl -Append
}
#Its a SharePoint Group, So search inside the group and check if the user is member of that group
else
{
                        foreach($user in $WebRoleAssignment.member.users)
                            {
   #Get the Group's Permissions on site
$WebGroupPermissions=@()
    foreach ($RoleDefinition  in $WebRoleAssignment.RoleDefinitionBindings)
  {
                      $WebGroupPermissions += $RoleDefinition.Name +";"
                      }
#write-host "Group has these permissions: " $WebGroupPermissions

#Send the Data to Log file
"$($Web.Url) `t Site `t $($Web.Title)`t Member of $($WebRoleAssignment.Member.Name) Group `t $($WebGroupPermissions) `t $($user.LoginName)" | Out-File $FileUrl -Append
}
}
                   }
}

#********  Check Lists with Unique Permissions ********/
           foreach($List in $Web.lists)
           {
               if($List.HasUniqueRoleAssignments -eq $True -and ($List.Hidden -eq $false))
               {
                  #Get all the users granted permissions to the list
           foreach($ListRoleAssignment in $List.RoleAssignments )
               {
                 #Is it a User Account?
if($ListRoleAssignment.Member.userlogin)  
{

#Get the Permissions assigned to user
$ListUserPermissions=@()
   foreach ($RoleDefinition  in $ListRoleAssignment.RoleDefinitionBindings)
  {
                       $ListUserPermissions += $RoleDefinition.Name +";"
                      }
#write-host "with these permissions: " $ListUserPermissions

#Send the Data to Log file
"$($List.ParentWeb.Url)/$($List.RootFolder.Url) `t List `t $($List.Title)`t Direct Permission1 `t $($ListUserPermissions)  `t $($ListRoleAssignment.Member)" | Out-File $FileUrl -Append
}
#Its a SharePoint Group, So search inside the group and check if the user is member of that group
else
{
                       foreach($user in $ListRoleAssignment.member.users)
                           {
   #Get the Group's Permissions on site
$ListGroupPermissions=@()
    foreach ($RoleDefinition  in $ListRoleAssignment.RoleDefinitionBindings)
  {
                      $ListGroupPermissions += $RoleDefinition.Name +";"
                      }
#write-host "Group has these permissions: " $ListGroupPermissions

#Send the Data to Log file
"$($Web.Url) `t List `t $($List.Title)`t Member of $($ListRoleAssignment.Member.Name) Group `t $($user.LoginName) `t $($user.LoginName)" | Out-File $FileUrl -Append

}
}
                 }
           }
           }
}
}

}

#Call the function to Check Users Access

$strA="http://server/sites/yoursite"; # provide SharePoint site URL
$strB="F:\users_PermisionReport.csv"; # provide csv file location to save the report
GetUserAccessReport($strA) ($strB)

Thursday, September 17, 2015

Shrinking the Database transaction log file in Microsoft SQL server 2008 and 2008 R2

To shrink the transaction log file we need to follow these simple steps below

1) It is good to take log file backup before we Shrink transaction log file, to back up the log file execute the below command

BACKUP LOG [SharePoint_Config] TO DISK=’D:\configLogBackup.bak’

2) You need to change the recovery model to simple

Change the DB model to simple (Right click on the SharePoint_Config and click on properties àOptionsàRecovery model: change it to SIMPLE
(OR)
ALTER DATABSE [<databasename>] SET RECOVERY SIMPLE
In the process of making the database recovery model to “Simple”, it truncates the transaction log file, as it is not used with the simple recovery model.

3) Shrink the SharePoint_Config_Log DB

DBCC SHRINKFILE(‘SharePoint_Config_Log’)
(OR)
If you want to shrink it to certain MB then you can use command like below
DBCC SHRINKFILE(‘SharePoint_Config_Log’,50)

4) Revert back recovery model to FULL

Change the DB recovery model to full (Right click on the SharePoint_Config DB and click on properties àOptionsà Recovery Model: Change it to FULL
(OR)
ALTER DATABSE [<databasename>] SET RECOVERY FULL




Wednesday, September 16, 2015

SharePoint 2013 web application Backup Script error: Cannot convert value to type System.String

In SharePoint 2013 environment one of the web application backup is failed and rest of all the web applications are successful

The error message was showing like below, 

Backup script error: Cannot convert value to type System.String

I found the problem that is backup running user account does not have access rights to few site collections inside the web applications. 

Solution:
Going to that particular web application and check if all the site collections does have the full access rights to the account which you used to run the backup job, If not grant full rights.

This worked for me ..


Monday, September 14, 2015

SharePoint user profile service application PowerShell commands



Sometimes we are unable to start and stop the User Profile Synchronization Service from GUI, still there is way using power shell

Using Get-SPServiceInstance

To get the list of all the services "guid" with Power Shell command, but it is difficult to identify the exact user profile service if we are using multiple user profile services so best use to save the services in to a Text file.  

Run the below command as shown.

Get-SPServiceInstance > Services.txt
It will writes the list of all the services with name and "guid" in to the text file

To Start the User Profile Synchronization Service use the following command


Start-SPServiceInstance –Identity "Guid of Particular Service Application"

To Stop the User Profile Synchronization Service use the following command

Stop-SPServiceInstance –Identity "Guid of Particular Service Application"

SharePoint 2013 - User Profile Service Stuck on Starting
When it stuck on starting run the following PowerShell command
Add-PSSnapin Microsoft.SharePoint.Powershell
$TypeName = "User Profile Synchronization Service"
$ServerName = "SERVERNAME" #Replace with your server name where the service is stuck on Starting
$Serviceinstance = Get-SPServiceInstance | where-object {$_.TypeName -eq $TypeName -and $_.Server.Address -eq $ServerName}
$Serviceinstance.Unprovision()

User Profile Service Application - Operation is not valid due to the current state of the object

When you  see the following error message, user profile incremental synchronization failed operation not valid due to the current state of the object. The reason why this error showing due to User Profile Synchronization Service is not running on server. We need to start the user profile synchronization service.

To fix this:
1. Browse to Central Administration
2. Go to System Settings --> Manage Services on Server
3. Select the server from the top right corner where the User Profile Synchronization Service is running.
4. Find the job in the list and it should be in a "Stopped" state 
5. Click on Start


This can take up to 15 minutes to get started so be patient. Once complete, try running a sync again. 

Thursday, September 10, 2015

Detaching and Reattaching a Content Database in SharePoint 2010/2013



Detach a Content Database

The easiest way to detach a content database is through the UI in Central Administration.

Central Administration -> Application Management -> Content Databases

Click on the link for the Content Database you want to detach. Make a note of the name of the database. Check the 'Remove content database' checkbox. Click OK. This removes but does not delete the database.

Using PowerShell to detach a content database:

Dismount-SPContentDatabase "contentdbname"

Attach a Content Database

To attach an existing content database:

Mount-SPContentDatabase "contentdbname" -DatabaseServer "SQLserver" -WebApplication  http://SiteName

Where:
·        "contentdbname" is the name of the content database
·        "SQLserver" is the name of the database server.
·        http://SiteName is the name of the web application to which the content database is being attached.

Wednesday, September 9, 2015

Finding a Correlation ID error information in SharePoint

One frustrating error SharePoint users will occasionally experience is the dreaded 'red X' with a cryptic correlation ID error. When that happens, the SharePoint Administrator must perform the equally frustrating task of looking through the logs to find the cause of the error.


Wouldn’t it be nice if there was a command that will search the log files for the correlation ID?  The command Merge-SPlogfile will automatically search the logs for the error ID. Better than that, the command will search ALL the servers in the farm and place a log file on the server that you will the command. 

Here is an example of the the Merge-SPlogfile command:
Merge-SPLogFile –Path –Correlation <Guid>

Example:

Merge-SPlogfile –Path D:\log.log –Correlation ba05e237-0680-403a-b9f6-e49f96ac55d4
(That will place a .log file on the D drive of the server which will only contain errors with the correlation ID.)

This one line of command will help to find the cause of the error quickly, this command will search in all the servers in the farm and place a log file on the server.


Move site collection to another content database using PowerShell commands

We can move SharePoint site collection from one content DB to another Content database. But before moving the database we need to check following things,
·   New content database should be exists on the same server and it needs to be under the same web application.
·   The account used to move the site collection should be WSS_ADMIN_WPG group and account need to have db_owner permissions.
To move the site collection to the new content DB create a new content DB in SharePoint central Admin by navigating to Application management -> Manage Content Database -> Create new Content Database

Run following command in SharePoint management shell,

Move-SPSite SiteCollection URL -DestinationDatabase Target_Content_DB_Name
Example:

Move-SPSite 'http://xyz:1234/sites/accounting'  -DestinationDatabase wss_content_accounting            

This operation will take time depending on the site collection size. 

SharePoint Health Analysis with PowerShell

Here is a quick tip that I use after having installed a SharePoint farm, in order to check its configuration.
It’s a PowerShell script that runs all health analysis jobs immediately. Once the jobs are done, you can navigate to “Monitoring” and then “Review problems and solutions” to check if anything is wrong.
THE HEALTH ANALYSIS SCRIPT
Get-SPTimerJob | where {$_.Title -like "Health Analysis *"}
$jobs = Get-SPTimerJob | Where-Object {$_.Title -like "Health Analysis *"}
foreach ($job in $jobs)
{
    $job.RunNow()
}

CHECK HEALTH REPORTS

Once the script has been run, navigate to the Central Administration of your SharePoint Farm.
In the “Monitoring” Section, click on “Review problems and solutions” to display a list of all health reports compiled by the health analysis jobs.

Read Only View in InfoPath forms

The form is going to open to the default view - sadly, it does not care what view it was on when it was submitted.

Add a field to your data source that doesn't show on your form - let's pretend you've named it "IsSubmitted" and it is a true / false field, and it is defaulted to false.

In your submit button, remove the rule to switch the view. Instead, before you submit to the library, set IsSubmitted to true.

Then, add a form load rule. In the form load rule, use the condition IsSubmitted is equal to true and the action can be to switch to the read only view.


Submitted forms should then open in Read Only 

SharePoint 2010 Service Account Password Change



My SharePoint Farm has multiple application pools including SharePoint Services running and each Application Pool is running on different service account.
To check which application pool is running using which service account.
Go to Run >> Type inetmgr. This will open Internet Information Services Manager.
Click on Application Pool and you can see Identity of Application pool which is Service account.



When we create Application Pool or Application Service and choose new service application pool account, this account get registered to Manage Accounts under Security.
Path will be Central Administration >  Security > Manage Accounts
We can see here are all service accounts are registered.

If you want to Check password of service account you can check using PowerShell command.
Open Windows PowerShell Module from All Application Program & type below PowerShell Command.

Get-WmiObject –Namespace root/MicrosoftIIsV2 –Class IIsApplicationPoolSetting –Property Name, WAMUserName, WAMUserPass | Select Name, WAMUserName, WAMUserPass

Then it will show all passwords of particular service account name.



This will help you in case you forget your AppPool Service Account password.
Now, we will change password of service account which is running a web application name Test – 45380. And you can see the service account name is spdev\testpass and password is P@ssw0rd3

For changing password of spdev\testpass go to Central Administration > Security > Manage Accounts
Look for spdev\testpass and edit.
Now check box named Change Password Now and select Set account password to new value.
Enter new password and click on ok.


 To confirm password is changed or not you can run above PowerShell script.


SharePoint 2010 - Checking Site Collection Quota Usage


This explains how to check the storage quota of a site collection..

Note: In order to check the storage quota you must be a site collection administrator or have been granted the "View Web Analytics Data" permission in the root site of your site collection.
Select Site Actions and then Site Settings

On the Site Settings page under the Site Actions heading, select Site Collection Web Analytics Reports

From the quick launch menu on the left, select Storage Usage under the Inventory heading to view current and historical information about your storage quota and usage.
Note: Files in the recycle bin are included in the site usage. You must empty the recycle bin to free up that space.

To configure diagnostic logging by using Central Administration

Using this we can control the amount of diagnostic information to be logged in SharePoint.


  1. Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.
  2. In Central Administration, on the Home page, click Monitoring.
  3. On the Monitoring page, in the Reporting section, click Configure diagnostic logging.
  4. On the Diagnostic Logging page, in the Event Throttling section, you can configure event throttling as follows:
To configure event throttling for all categories:

    1. Select the All Categories check box.
    2. Select the event log level from the Least critical event to report to the event log list.
    3. Select the trace log level from the Least critical event to report to the trace log list.
To configure event throttling for one or more categories:

    1. Select the check boxes next to the categories that you want.
    2. Select the event log level from the Least critical event to report to the event log list.
    3. Select the trace log level from the Least critical event to report to the trace log list.
To configure event throttling for one or more sub-categories (you can expand one or more categories and select any sub-category):

    1. Click (+) next to the category to expand the category.
    2. Select the check box next to the sub-category.
    3. Select the event log level from the Least critical event to report to the event log list.
    4. Select the trace log level from the Least critical event to report to the trace log list.
To configure event throttling for all categories back to default settings:

    1. Select the All Categories check box.
    2. Select Reset to default from the Least critical event to report to the event log list.
    3. Select Reset to default from the Least critical event to report to the trace log list.
  1. In the Event Log Flood Protection section, select the Enable Event Log Flood Protection check box.
  2. In the Trace Log section, in the Path box, type the path of the folder to which you want logs to be written.
  3. In the Number of days to store log files box, type the number of days (1-366) that you want logs to be kept. After this time, logs will automatically be deleted.
  4. To restrict how much disk space the logs can use, select the Restrict Trace Log disk space usage check box, and then type the number gigabytes (GB) you want to restrict log files to. When logs reach this disk size, older logs will automatically be deleted.
  5. After you have made the changes that you want on the Diagnostic Logging page, click OK.

Content Database Status Error in SharePoint 2010 Central Administration

In  SharePoint 2010 environment, I have number of content databases in a web application, I found one of my content database showing error under the database status column in manage content database section in central administration, rest of them all are showing status started.

Resolution:
I clicked on content database and hit ok without changing anything and status became –Started.

I just wanted to check the content database status in SQL server database,
I used this below query to check the Content DB status,

SELECT DB_NAME() AS DatabaseName, DATABASEPROPERTYEX('Specify database name', 'Status') AS DBStatus