Saturday, August 31, 2013

In some
cases, I have seen site collection quotas are turned to "Individual Quota" in database attachment method, even I copied the quota templates before
database attachment. All quota settings are lost! I dunno the cause of this issue and want to apply site collection quota to existing sites.

Thursday, August 29, 2013

SharePoint site collection administrators have Full rights to all sites within a site collection. Primary site collection administrator and Secondary site collection administrator specified in central administration will automatically become site collection admins. Its also possible to add multiple site collection admins for any SharePoint site collection.

How to add site collection administrator in SharePoint?
To add site collection administrator in SharePoint, you must be either Farm Administrator or another Site Collection Administrator of the site collection. Navigate to Site Settings >> Click on "Site collection administrators" link under "Users and Permissions"

which will lead you to a page where you can manage site collection administrators.

How to Add Site Collection Administrators Programmatically with C#?
In some scenarios, we may have to add site collection administrators programmatically. Say for e.g. There may be a requirement to add a particular user as site collection administrator to multiple site collections. Here is the code to add site collection administratorprogrammatically:

Add site collection administrator SharePoint 2010 with PowerShell
The above code can be transformed to PowerShell to add site collection administrator SharePoint 2010 programmatically. Here is how to add site collection administrator in SharePoint 2010 using PowerShell:

By default, Wildcard search is not enabled in SharePoint! Say for e.g. If you search for "Script" you will get results for the search
query. But if you want to search using partial words ("sc" for "Script") that aren't complete, You will not get the search results until you add the wildcard character * in your queries (sc*)

Here are the screens to explain the above scenario: Search results for the complete word: Script
Search results for the partial word: Sc
Yes, You can always add a wildcard character * in your queries: E.g. sc* to perform wildcard search in SharePoint 2010. But how to make it
default without you/end-user entering the wildcard character every time?

Sure, We can enable wildcard search in SharePoint by default! here is how:

That's all . We have enabled SharePoint Server 2010 wildcard search! Wait for a moment for the search service to reflect your changes and see the result in action. We've typed "sc" as search string and SharePoint returned results for: sc*

The above method can be use to apply wildcard people search in SharePoint 2010 too!

Solution:
One quick solution is simply Flip the value of "Allow this list to receive e-mail?"

Just go to List Settings

Under Communication, click on "Incoming e-mail settings" link

Select "Allow this list to receive e-mail?" to "No" and click on "Save"

Now, go back to the Incoming e-mail settings again and choose ""Allow this list to receive e-mail?" to "Yes" and then save your changes.

We can also automate the above activities with PowerShell.

Wait, There is an elegant solution yet:
However there is an another efficient way by: Calling RefreshEmailEnabledObjects() method of SPSite object to refresh all Incoming Email settings! (or use: stsadm -o refreshdms command). Here is the PowerShell script:

Friday, August 16, 2013

Site collection administrators are administrators of the site collection with full control to the entire site collection including top-level site and all of its subsites, lists and libraries in the site collection.

How to Remove Site Collection Administrator in SharePoint?
To remove SharePoint Site Collection Administrator, we use "Site collection Administrators" link from site settings.

You must be a Farm Administrator or site collection administrator to see this link, BTW! From this page, we can delete site collection administrators.

PowerShell to Remove Site Collection Administrator:
We may have to remove site collection administrators programmatically. Lets use PowerShell in SharePoint to remove site collection administrator:

Note that, You can't leave site collection Administrators empty! Usually primary/secondary site collection administrators are assigned through SharePoint Central Administration site. If you want to change a Primary/Secondary Site collection administrator using Central Administration/PowerShell/Stsadm tool, refer my post: How to Change Site Collection Primary, Secondary Administrators in SharePoint

Thursday, August 15, 2013

SharePoint quota templates enables us to keep the site collections growth in control. It defines the maximum amount of data stored in a site collection and prevent from disk fillings! Quota template makes it easier to govern site collections growth by assigning a pre-defined sizing template to them, rather assigning individual quotas to each site collections in the farm. Quota templates set how much storage space a site collection can occupy.

Quota templates offer two levels: Warning Level and Maximum Storage Level.Once the site collection reaches warning level, SharePoint triggers an Email to site collection administrators and further addition to site is possible until it reaches to Maximum storage level.

How to Create a New Quota Template in SharePoint 2010?
Creating new quota template in SharePoint 2010 is relatively simpler! Go to:

Central Administration >> Application Management

Click on "Specify quota templates" under "Site Collections" group

On the quota templates page click on "Create a new template"

Give a Name to your new Quota Template

Specify the maximum of storage limit, warning limits of the quota template.

Sunday, August 11, 2013

What is Visual Upgrade in SharePoint 2010?
Lets understand visual upgrade in SharePoint 2010. In short: It's a feature introduced in SharePoint 2010 to ease up transition from MOSS 2007 user interface to SharePoint 2010 UI. When sites migrated from MOSS 2007 using database attach method, They will be using the v3 interface by default and we got to update it.

SharePoint 2010 Visual Upgrade to all Sites:
To apply visual upgrade on a single site, Navigate to:

Site Actions >>Site Settings

Click on "Title, Description, and Icon", Choose the Visual Upgrade option to : Update the user interface and click on OK.

Clicking on "Site Actions >> Visual Upgrade" also will lead to the same URL (/_layouts/prjsetng.aspx)

To visual upgrade entire site collection (all sites):

Navigate to Site Actions >> Site Settings

Click on "Visual Upgrade" link under Site collection Administration >> Click on "Upgrade All Sites" button.

SharePoint
2010 visual upgrade all sites with PowerShell: We can apply visual
upgrade programmatically with PowerShell. Here is my article on
SharePoint 2010 visual upgrade using PowerShell script: Visual upgrade all sites in a site collectionVisual Upgrade options missing?
Remember, its available only on sites migrated/upgraded from SharePoint 2007 and Not for sites created in SharePoint 2010 itself. Also, once sites are upgraded to SharePoint 2010 look and feel, Visual upgrade options will disappear!

Also, If you clicked on "Hide Visual Upgrade" button from Site collection administration, that hides visual upgrade options from Site settings menu as well as from "Title, Description, Icon" link under site settings. It removes Visual upgrade notification as well. We can enable it back with PowerShell. By default, Its not available on sites created in SharePoint 2010.

Visual Upgrade Buttons Disabled (Greyed out)?
Its available only on sites migrated/upgraded from SharePoint 2007 and Not for sites created in SharePoint 2010 itself. Both of the buttons "Hide Visual Upgrade" and "Update All Sites" under Visual Upgrade page (/_layouts/suppux.aspx) disabled in site collections created in SharePoint 2010.

Enable Visual Upgrade Options
If visual upgrade options missing due to any of the reasons discussed above, We can bring it back with PowerShell. Here is how to enable it for single site (subsite or rootsite):

Getting access is denied during visual upgrade?
You may get access denied error during visual upgrade when your site collections are locked or Database is in read-only mode. Check database status from SQL Server management studio. To Unlock any site collections, use: Set-SPSite -Identity <Site-collection-url> -LockState Unlock
Fore more info on site collection locks, refer: Site Collection Locks in SharePoint 2010

Visual Upgrade Rollback
So you upgraded to SharePoint 2010 UI and want to reverse visual upgrade? Sure, We can rollback SharePoint visual upgrade and revert to MOSS 2007 user interface using this PowerShell script.

#Get the site collection
$Site = Get-SPsite http://SiteCollection-url
#Enable Visual upgrade on Each site
foreach($web in $site.AllWebs)
{
$web.UIVersion = 3 #set the UI version to SharePoint 2007 look and feel
$web.Update()
}

How do I Visual Upgrade All Site Collections using PowerShell:
To convert all SharePoint 2007 sites UI to SharePoint 2010:

Get-SPSite | foreach-object {$_.VisualUpgradeWebs()}

Get Visual Upgrade Status:
To verify SharePoint 2010 sites visual upgrade status, we can get the status for all sites under given site collection with PowerShell:

Thursday, August 8, 2013

SharePoint Central Administration site got deleted from IIS accidentally! It may happen due to file system got
corruption errors. No worries, We can Re-provision SharePoint Central admin site! Lets provision SharePoint central administration site using PowerShell.

Replicating directory changes permission is a requirement to configure User Profile Service Application(UPS) in SharePoint 2010 and for SharePoint 2013. We've to grant replicate directory changes permission on a domain to our service account which crawls and syncs AD contracts to SharePoint.

I just had to generate a report to find SharePoint site collection administrators and see who are all assigned with Site collection administrator rights on various site collection in entire SharePoint Farm.

Sure, Lets use PowerShell in SharePoint to get site collection administrator programmatically. This script iterates through all site collections in all web applications to list site collection administrators.

PowerShell Script to Get All Site Collection Administrators (I've made it compatible with SharePoint 2007)

Wednesday, August 7, 2013

I was trying to write a PowerShell script to retrieve user profile properties in SharePoint 2013, and ended up with the below error:

"UserProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have c4a5371c-01c2-4281-b91b-ca335982f994"

Solution:
After verifying user profile service application and SharePoint timer jobs are up and running, arrived to the right destination: User profile service application permissions! Grant "Full Control" permission to the account running the code on User profile Service application.

We may have to run SharePoint timer jobs on-demand in some situations. Say for e.g. To update Rating values, I had to run the timer jobs: User Profile Service Application - Social Rating Synchronization Job and User Profile Service Application - Social Data Maintenance Job. Read more at SharePoint 2010 Rating Feature Configuration

How to run timer job manually in SharePoint?
So, To run a SharePoint 2010 timer Jobs on-demand, we used to navigate to Central Administration >> Monitoring >> Timer Jobs >> Review Job Definition >> Pick the timer jobs we want to run >> Click on "Run Now", BTW SharePoint 2007 doesn't offer way to run timer job manually!

This will run timer job immediately in SharePoint 2010.

SharePoint 2013 run timer job from PowerShell:
We can run timer job from code.

Monday, August 5, 2013

Ever wanted to enable a feature on all site collections in a SharePoint environment? Well, To activate a site collection feature in SharePoint, navigate to Site settings >> Site Collection Features >>
Click on "Activate" next to the relevant feature.

How to Activate a Feature using PowerShell?
To activate a SharePoint feature on a particular site, we use: Enable-SPFeature cmdlet.

Create SharePoint Group Programmatically with PowerShell:
Use this function to create a SharePoint group using PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function Create-SPGroup($SiteURL, $GroupName, $GroupOwner,$GroupDescription)
{
<#
.Description
This PowerShell function Creates new SharePoint Group on the given site collection URL
.Example
Create-SPGroup "http://sharepoint.crescent.com/sites/operations" "Operation Managers" "Global\salaudeen" "Group for Operation Managers"
This example Creates new SharePoint group "Operation Managers" at the given site collection
.Link
http://www.sharepointdiary.com
http://twitter.com/SharePointdiary
.Inputs
$SiteURL - Site collection URL in which the group to be created
$GroupName - Name of the Group to be create
$GroupOwner - Existing user account, By default only Group owner can edit members of the group
$GroupDescription - Descriptive text for the group
.Outputs
Gives message on the screen on Group Creation/Failure
#>
#Get the RootWeb
$web = Get-SPWeb $SiteURL
#Get Group Owner
$GroupOwner = Get-SPUser -Identity $GroupOwner -Web $web
#if the group doesn't exists already
if($Web.SiteGroups[$GroupName] -eq $null)
{
#create sharepoint user group programmatically
$web.SiteGroups.Add( $GroupName, $GroupOwner, $GroupOwner, $GroupDescription)
#Get the Group
$NewGroup = $Web.SiteGroups[$GroupName]
#Set Group Properties
#$NewGroup.AllowMembersEditMembership = $true
#Assign Permissions to the Group
$GroupAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($NewGroup)
#Get Full Control Role (Permission Level)
$GroupRoleDefinition = $web.Site.RootWeb.RoleDefinitions["Full Control"]
#Bind Full Control
$GroupAssignment.RoleDefinitionBindings.Add($GroupRoleDefinition)
#Grant Full control to the Web
$web.RoleAssignments.Add($GroupAssignment)
$web.Update()
Write-Host "New Group Created!"
}
else
{
Write-Host "Group already Exists!"
}
$web.Dispose()
}
#Call the function to create a SharePoint user group programmatically
Create-SPGroup "http://sharepoint.crescent.com/sites/operations" "Operation Managers" "Global\Salaudeen" "Group for Operation Managers"

Delete SharePoint Group Programmatically with PowerShell:
And to delete an existing SharePoint group programmatically, the PowerShell code goes like:

Function Delete-SPGroup($SiteURL, $GroupName)
{
<#
.Description
This PowerShell function Deletes an existing SharePoint Group on the given site collection URL
.Example
Delete-SPGroup "http://sharepoint.crescent.com/sites/operations" "Operation Managers"
This example deletes SharePoint group "Operation Managers" at the given site collection
.Link
http://www.sharepointdiary.com
.Inputs
$SiteURL - Site collection URL in which the group to be created
$GroupName - Name of the Group to be create
.Outputs
Gives message on the screen on Group Deletion/Failure
#>
#Get the RootWeb
$web = Get-SPWeb $SiteURL
#if the group exists
if($Web.SiteGroups[$GroupName] -ne $null)
{
#remove sharepoint group using powershell
$web.SiteGroups.Remove($GroupName)
$web.Update()
Write-Host "Group Deleted!"
}
else
{
Write-Host "Group doesn't Exists!"
}
$web.Dispose()
}
#Call the function to delete sharepoint groups using powershell
Delete-SPGroup "http://sharepoint.crescent.com/sites/operations" "Operation Managers"

PowerShell is a handy way to perform tedious and repetitive tasks in SharePoint. Say, we want to add or remove a choice value in a specific choice column for number of sites, get or update choice column values, etc.

Here are some nifty PowerShell scripts to manage choice field in SharePoint.

How to Add New Choice Field to SharePoint List using PowerShell
Lets use PowerShell to create choice column:

Thursday, August 1, 2013

Problem Scenario:
End-users actively started using their "My Sites" and most of their My sites reached the site collection storage quota limit of 100MB! Gradually started receiving many requests to increase storage limits.

That's enough! This should fix the problem, isn't it? Unfortunately NO! Users still receiving "Your changes could not be saved because this SharePoint Web site has exceeded the storage quota limit." error while trying to upload a file or add new item to their SharePoint site.
Went to Central Administration, Verified again that Site collections has enough space to accommodate new items.

In short: Even if you increase a quota template's limits, it won't reflect on site collections which are already using that quota!

Fix:
Updating an existing SharePoint site quota template's
quota limits will not automatically increase the quota limits for the
site collections which are already using that particular quota. Site
collections which are using the particular quota still be showing old
quota values. So, the fix is: Switch the Quota template of the site collection to some thing else and then switch it back to its original quota.
Here is how: Go to

Central Administration >> Application Management

Click on "Configure Quotas and locks" under site collections group

Change the site collection's quota template to a different quota template (In my case its "Starter"). Click OK to save changes.

Now, go back to Configure Quotas and locks and specify the old template ("Personal" in my case!) again. Click "OK" to save the changes.

That's all! Problem solved? Yes, kind of! but are we going to do the same for our 100+ site collections? May be, depends on your time! but sounds like a bad idea!! So, Lets use PowerShell to automate this.