Tag Archives: sharepoint hosting

SharePoint 2013 Hosting – ASPHostPortal.com :: How to Add or Remove A New User to SharePoint Group Using Powershell Script

How to Add or Remove A New User to SharePoint Group Using Powershell Script

In SharePoint site you can see usually a lot of groups. Sometimes administrator gets a task to add user to several groups. If it’s 3-5 groups you can do it manually, but if you need to add user to 30 groups? I’m too lazy to do it manually and too smart not do it at all.

SharePoint 2013 Hosting

  1. Start your windows PowerShell on your computer.
  2. Right click and select Run as administrator option.
  3. Paste the below script on the PowerShell window and click the enter button.
  4. Check your SharePoint site Feature will activated successfully.

So let’s start out PowerShell ISE and connect SharePoint CMD-let:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{ 
 Write-Host "Connect Sharepoint cmd-Let" 
 Add-PSSnapin Microsoft.SharePoint.PowerShell 
}

Let’s enter site collection url, username for inserting to groups and get array of destination SharePoint groups. For example, let this groups contain a string “admin”

$url = "http://user"
$userName = "user\testuser1"
$site = new-object Microsoft.SharePoint.SPSite($url) 
$web = $site.OpenWeb() 
$groups = $web.sitegroups
write-host "------get array of groups which contain a string "admin"-----" 
$myGroups = @(); 
foreach($group in $groups) { 
if($group -match "admin") { 
$myGroups += $group 
}

Go through each element of array and add user to SharePoint group

foreach ($gr in $myGroups) { 
#add user to SP Group
 Set-SPUser -Identity $userName -web $url -Group $gr 
 write-host "User " $userName "added to " $gr 
}

And if you made a false and, for example, entered wrong username, you can easily remove user from SharePoint groups with this PS-code:

foreach ($gr in $myGroups) { 
 $theGroup = $web.SiteGroups[$gr] 
 $theUser = $web.AllUsers.Item($userName) 
#Remove user from SP Group
 $theGroup.RemoveUser($theUser); 
 write-host "User " $userName " removed from " $gr
}

If you don’t want to collect these pieces here’s a full version:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{ 
 Write-Host "Connect Sharepoint cmd-Let" 
 Add-PSSnapin Microsoft.SharePoint.PowerShell 
}
$url = "http://user"
$site = new-object Microsoft.SharePoint.SPSite($url) 
$web = $site.OpenWeb() 
$groups = $web.sitegroups 
$userName = "user\testuser1" 
write-host "--------------" 
$i = 0; 
$myGroups = @(); 
foreach($group in $groups) { 
 if($group -match "admin") { 
 $myGroups += $group 
 } 
} 
foreach ($gr in $myGroups) { 
 write-host $gr 
#add user to SP Group
 Set-SPUser -Identity $userName -web $url -Group $gr 
 $theGroup = $web.SiteGroups[$gr] 
 $theUser = $web.AllUsers.Item($userName) 
#Remove user from SP Group
# $theGroup.RemoveUser($theUser); 
 write-host "User " $userName "added to " $gr 
}

If there are non-english letters in a group name or if the group you need is on another site (but in this site collection), then you can have error on Set-SPUser command. In this case I can advice you to use another command $web.SiteGroups[group name].AddUser(user)

foreach ($gr in $myGroups) { 
 Write-Output "Группа: $gr " 
#alternative way to add user to SP Group 
 $theUser = $web.AllUsers.Item($userName)
 $web.SiteGroups[$gr].AddUser($theUser) 
 Write-Output "User $userName added to $gr" 
}

Cheap and Recommended SharePoint 2013 Hosting

ASPHostPortal.com is Perfect, suitable hosting plan for a starter in SharePoint. ASPHostPortal the leading provider of Windows hosting and affordable SharePoint Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.

Sharepoint 2013 Hosting – ASPHostPortal.com :: User Profile Property Cannot be Deleted in SharePoint 2013

If you run into the problem that you can’t delete properties within the User Profile Service Application, an Exception like this will be shown:

User Profile Property Cannot be Deleted in SharePoint 2013

The delete operation failed, please try again later. If the problem persists, please contact your administrator.

To resolve the problem, grant “Full Control” permissions to the administrative Applicationpools group (WSS_WPG).

User Profile Property Cannot be Deleted in SharePoint 2013 2

Now you should be able to delete properties again.

Cheap and Recommended SharePoint 2013 Hosting

ASPHostPortal.com is Perfect, suitable hosting plan for a starter in SharePoint. ASPHostPortal the leading provider of Windows hosting and affordable SharePoint Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability

SharePoint 2013 Hosting – ASPHostPortal.com :: How to Fix SharePoint Cannot Show The Value of Filter

Multi-valued PeoplePicker Column that can be filtered using PowerShell

Recently I came across an error while filtering the multi-valued PeoplePicker column. The error reads “Cannot show the value of filter“. The field may not be filterable, or the number of items returned exceeds the list view threshold enforced by the administrator.” There are only four values in the column, surely it has no relation to the list view threshold value.

ahp banner sharepoint-01

Internally, SharePoint server uses “_layouts/filter.aspx” application page for filter values which are presented in an iFrame. I checked the ULS logs and copied the Request URL with filter.aspx. I pasted it in browser and hit “Enter”. It returned no result.

What is multi-valued field?

The field which allows more than one values or which allows multiple selections. The multi-valued fileds are non-sortable, non-filterable. Multi-valued fields cannot be indexed.

How to Fix

This behavior can be overridden. Every field has an associated schema. Multi-valued fields are marked as “Sortable =false” in the schema for performance reasons. Note: Apply the workaround wherever it is unavoidable.

If we mark the multi-valued PeoplePicker as “Sortable=true”, the column turns filterable/ sortable. This can be achieved using SharePoint Server Object Model or using Windows PowerShell (I love it).

PowerShell Script to mark the column as Sortable:

$web=Get-SPWeb <weburl>
$list=$web.Lists[<list title>]
$field=$list.Fields[<field title>]
$strSchema=$field.SchemaXml
$str=Schema$strSchema.Replace(“Sortable=`”FALSE`””,”Sortable=`”true`””)
$field.SchemaXml = $strSchema

Update: I noticed that multi-valued “person or group” column in other web application was showing filter choices even though “Sortable=false”. Googling did not help. I checked at various levels and found that “Online Presence” setting causes this error. If Online presence setting is turned OFF, SP 2010 starts showing this error for multi-valued columns when tried to filter. So turn it ON, and no error, filter choices are shown back. The Online Presence setting is available in Web applications’s General Settings.

Cheap and Recommended SharePoint 2013 Hosting

ASPHostPortal.com
ASPHostPortal.com is Perfect, suitable hosting plan for a starter in SharePoint. ASPHostPortal the leading provider of Windows hosting and affordable SharePoint Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability

SharePoint 2013 Hosting – ASPHostPortal.com :: Creating Web Application From Existing Content Database

There are situations where you want to propagate one SharePoint web application to some other farm/machine. I feel the fastest way is to take content database backup and restore it in your destination farm. I have done so in last couple of weeks and I have leaned how to quickly do that. I was provided with content database backup and source code. That makes be able to restore site and generate wsps from source code.

banner promo-01Creating  content database from backup

Go to your database server and do following:

  • Create a blank database that will be used as content database
  • Restore a database using content database back up from source farm.

Creating a web application:

  • Go to sharepoint central administration and create a new web application
  • While creating a new web application, use existing content database in database section
  • Sometimes if your database is too large, web application creation takes too long and times out. Don’t worry at all. web application is still created successfully. It happened to me 4 times out of 5.

Validating the web application:

  • Go to sharepoint central administration, click on application management. In “Databases” section you will find “Manage content databases”
  • Choose your application and it will show database status and number of site collections. If you are not sure how many site collections are there in backup, anything greater than 0 is good news.

Configure web application to work properly. we are almost done now. Do following:

  • Go to sharepoint central administration
  • Click on “Application Management”
  • In “Site Collections” section click on “Change site collection administrators.
  • choose your web application set proper data in site admins.

Additional optional steps:
After performing all the above steps, it is still possible that you are not able to access your web application.

  • Last thing to do is to install and deploy wsp by using stsadm or your favorite method.

Conclusion:

It is always challenging to move applications from one farm to another. Specially when they are depending upon other service applications. In spent last two weeks to learn how to properly do that. I hope this will help you at some point during your sharepoint development.

SharePoint 2013 Hosting with ASPHostPortal.com :: Search Feature Not Working, How to Fix it?

When we test search feature in SharePoint 2013, it stop working and this is the error message:

The Problem

Turns out, the issue was due to URLs being configured in the Content Sources that either didn’t exist, or did not have a proper DNS entry that pointed the server to the correct location.

How to Fix it?

  • Navigate to Central Administrator
  • Click Application Management
  • Click Manage service applications
  • Click Search Service Application
  • Under Crawling section click Content Sources
  • Click Local SharePoint Sites
  • In the Start Addresses section (see below) remove all URL’s that do not exist

  • Click OK
  • Then try again and it should work now

Why are these URL’s a problem?

Our search server was locking up whenever a crawl would run. This meant that a full crawl or even an incremental crawl never finished. Obviously the issue was due to the site not existing or not being available for the crawler to index the content.

Hope this issue really help you all.

SharePoint 2013 Hosting with ASPHostPortal :: Tips SEO for Your SharePoint 2013 Site

As we may know that SharePoint 2013 has introduced many new features that more interesting than previous SharePoint. In this article, we will share how to optimize your SharePoint site. We are going to show you a few simple things you can do with your SharePoint Online website which will help you get started with your quest for the search rankings.

1. Use SEO Tools

This might sound obvious, but remember to use the tools that are provided. You don’t have to just jump straight into code to get started with your SEO. SharePoint Online Public website gives you a couple of tools to manage your Meta tags, as well as allowing you to choose custom URLs for pages.

Metadata

HTML Meta tags used to be the most recognized way to bump a page up in the search results page. Meta tags influence has been greatly reduced by most search engines, and they probably won’t help you increase your search ranking.

However, it has been suggested that leaving out Meta tags can negatively impact your search ranking. This means it’s still well worth adding Meta tags to the page; this is especially the case with your SharePoint Online Public website, as it has been made incredibly easy to add keywords to your pages.

To manage your Keywords, go to any page and select “Page” from the ribbon. From here, you can go to Edit Properties > Edit SEO Properties.

image-1

You can also manage site-wide Meta tags by going to Site Settings > Search engine optimization settings. This page lets you add Meta tags to the whole of your site.

In their example, it is useful for verifying your site for “Some Internet search engines” and their webmaster tools. You can then choose whether to actually use the Meta tags or not.

Page URLS

The URL of a page can sometimes play a significant role in the discoverability of a site. If a URL is kept short, simple and relevant, it makes it easier for both search engines to describe the content, and users to remember the link to get straight back to that content.

You can update any pages URL by navigating to the page, opening it edit mode, and clicking Edit Properties > Edit Navigation Properties

image-3

From here, you can select your new URL. This screen also lets you update how the page appears in your sites navigation.

You can also give it some descriptive text which will appear when you hover over it in the navigation. Again, it’s usually good to make this text descriptive, including keywords that are relevant to the destination page.

image-4

2. Change the Robots.txt File

The robots.txt file defines what content a search crawler is and is not allowed to index. This doesn’t mean that a user cannot get to that content, it just means that a search engine should never display that page when a user searches for your site.

You can get to this by going to Site Settings > Search Engine Sitemap Settings. SharePoint will have already set up a couple of the obvious one’s for you.

image-5

At this point, you can disallow any of the pages, or directories that you don’t want to be crawled. We’d recommend disallowing the crawling of any List pages, if that content is already being surfaced somewhere else on your site.

This is mainly because it’s of no use to your site visitors, but it could also potentially be seen as spam content. This is because it’s likely to be very keyword heavy, and also very similar (content wise) to the page that it is being surfaced on.

3. Create Simple Master Page

The default master pages that are provided on SharePoint Public Websites are the same master pages that are used for internal SharePoint sites.

This means that there is a lot of extra code in the master page which can mean sloppy HTML, and unnecessary file downloads. If you customise your master page, you can ensure that you have cleaner code, and make use of better Meta tags and micro formats to increase the machine readability of your site.

4. Check Your Documents

In many circumstances, the main content which a site is offering is actually stored in documents, and not in web pages. This content comes in forms of PDFs and Word documents to name but a few.

If you want this content to be indexed, you must think about how a search engine will find it. If you are just uploading a document to a document library, will it ever be read? There are 2 quick ways of improving the chances of somebody finding this document

Please follow this steps how to implement it:

The first way is to ensure your document names contain keywords describing the contents of the document. For example, the URL for a pdf uploaded to your documents library may look something like this: ‘/documents/blog-improve-sharepoint-site-seo.pdf’. This means that the content of the document is clear to both your site users and a search engine.

Our second tip to improve the way you offer documents, is to ensure that you are linking to your documents from other places in your site. This is a general rule for any type of site, however it is especially relevant for SharePoint 2013. Document libraries and Lists are often rendered with Client Side Rendering in SharePoint 2013.

What does this mean to SEO? When the page loads, none of the content from your document library is rendered as HTML. Instead, a large JavaScript object is created, and then transformed into HTML dynamically after the page has downloaded. This will mean that a search engine will not easily be able to read this list or library.

This can be seen if you look at the snippet that Google shows for some of your pages. Whilst we was writing this blog, we noticed that page with the Documents app on was displaying as : “javascript:commonShowModalDialog(‘{SiteUrl}’+ ‘/_layouts/15/itemexpiration.aspx’ +’?ID={ItemId}&List={ListId}’, ‘center:1;dialogHeight:500px”.

This is useless to a user, and does not inform them what this page is about. By following the tips above about Meta tags, this may prevent this from happening, however it will still not find the links to the document. Instead you should be linking directly to the document. When you do this, it’s also a good idea to set the text of the link to some keywords, rather than just “download” or something equally ambiguous.

So there’s our quick tips on improving the search rating of your SharePoint Online Public Site. There are probably a lot more things you can do to help improve it, and as Office 365 (2013) approaches General Availability, we hope to be adding some more details around the topics above in the near future.