SharePoint 2010
Powershell: Return SPWebTemplateNameByWebTemplateId
by mysticslayer on Nov.10, 2011, under Powershell, SharePoint 2010, SharePoint Foundation
Sometimes you it’s easy to script some stuff, and you redo some stuff. For example: You want to manually script your export-import action in SharePoint automatically.
Something you need by importing the site is the webtemplate before you can start the import. So, what you can do before deleting the site is to extract the WebTemplateId. The WebTemplate in $web.Url is not sufficient, because it doesn’t translate the correct Configuration.
So, what I’ve did is to use the WebTemplateId and get the according WebTemplate Name. And use it to create a SPSite.
function Get-SPWebTemplateNameBySPWebTemplateId($WebTemplateId) { $templates = Get-SPWebTemplate | Sort-Object "Name" $templateValues | ForEach-Object { if($_.ID -eq $WebTemplateId) $templateName = $_.Name return; } return $templateName } $templateName = Get-SPWebTemplateNameBySPWebTemplateId -WebTemplateId 53 Write-Host = $templateName
Above will return BLANKINTERNET#2
Use Content by Query Web Part on a Fixed List created dynamic in an onet.xml
by mysticslayer on Nov.07, 2011, under features, Programming, SharePoint 2010
There is nothing as worse as a Content By Query Web Part that you can’t use when you want to fix it against a List which will be made automatically for example.
I would like to create a Team Site based on a Custom Web template with an extra sub-site with blogging functionality. This blogging functionality is used for exposing news of the Team or Department.
But when using the functionality like
<Property name=”WebUrl” type=”string”>~site/News</Property>
and using the property
<Property name=”ListName” type=”string”>Posts</Property>
and you removed the value of the property
<Property name=”ListGuid” type=”string”></Property>
it won’t render the CQWP web part by default. The reason is that the ListGuid is needed to render the Web Part.
But also an issue is that, when your list is created it has a changed ListGuid. The ListGuid is never the same when you create a new List.
So basically I created the follow code which will fix that issue.
using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.Publishing; using Microsoft.SharePoint.Publishing.WebControls; namespace AK.Custom.CQWP { [ToolboxItemAttribute(false)] public class AKCQWP : ContentByQueryWebPart { protected override void OnLoad(EventArgs e) { if(!string.IsNullOrEmpty(this.WebUrl) && !string.IsNullOrEmpty(this.ListName) && string.IsNullOrEmpty(this.ListGuid)) { SPWeb webRoot = SPContext.Current.Site.OpenWeb(); if (this.WebUrl.StartsWith("~site")) { this.WebUrl = this.WebUrl.Replace("~site", ""); using(SPWeb web = SPContext.Current.Site.OpenWeb(webRoot.ServerRelativeUrl + this.WebUrl, true)) { SPList list = web.Lists[this.ListName]; this.ListGuid = list.ID.ToString(); //this.ListUrl = webRoot.ServerRelativeUrl + this.WebUrl; this.WebUrl = webRoot.ServerRelativeUrl + this.WebUrl; }; } else if(this.WebUrl.StartsWith("/News")) return; else { using(SPWeb web = SPContext.Current.Site.OpenWeb(this.WebUrl, true)) { SPList list = web.Lists[this.ListName]; this.ListGuid = list.ID.ToString(); this.WebUrl = this.WebUrl; }; } } base.OnLoad(e); } protected override void OnInit(EventArgs e) { base.OnInit(e); } protected override void CreateChildControls() { base.CreateChildControls(); } } }
When you have created this part of your solution ensure that you Export the standard CQWP and edit it like you want to. First of all, what you need is to ensure that it takes your assembly instead of the default CQWP assembly.
<metaData> <type name="AK.Custom.CQWP.AKCQWP, $SharePoint.Project.AssemblyFullName$" /> <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage> </metaData>
Change the properties as following:
<Property name=”WebUrl” type=”string”>~site/News</Property> <Property name=”ListName” type=”string”>Posts</Property> <Property name=”ListGuid” type=”string”></Property>
sharepoint 2010: localized resource for token ‘direction’ could not be found for file with path
by mysticslayer on Nov.07, 2011, under features, Programming, SharePoint 2010, SharePoint Foundation
A quick blog about the ‘Localized resource for token ‘direction’ could not be found with path ‘feature path’ is an issue when you have generated a List Definition. When you deploy a list definition in a feature without a Default Core Resource file you will run against this message. It seems to be introduced by the 2010 December update, and it also seems to be solved by the SP1 of 2011 June Refresh update, but I can’t say for sure.
I have installed some language packs on my dev machine, and it does work without any problems, but the environment I want to deploy to seems to have this issue for one reason or another.
Feature Deployment SharePoint 2010 (List Instance and List Definition)
by mysticslayer on Nov.07, 2011, under features, General, maintenance, Powershell, SharePoint 2010, SharePoint Foundation
So I started out today debugging some weird issues regarding feature deployment. And well sometimes I don’t know why I get errors, but what’s new. So first of all, let’s start where to start.
cannot complete this action.please try again
Starting point:
A colleague of mine had written a feature for a customer of us, which worked perfectly. The customer had never issues like it should. After almost a year we (me, and the customer) decided to change the full Site Templates. Like a developer should do is making and changing the solution work. Well then comes the burden. After days of work, testing everything out the solution worked by me. (Owwh yeah, the known starting point: well on my computer it works).
So after deployment at the production server it didn’t work. I didn’t knew why, because everything should work like my notebook. The reason is simple, I had the same configuration, databases, etc. Well that didn’t work that out to.
So I thought well, let’s start fresh with new content databases from production. Ahh yes, there we go. Well, at my notebook it didn’t work either. Whoehoe, nice, we’ve got a good starting point for debugging.
Visual Studio 2010:
So I worked with Visual Studio 2010 and the deployed the feature again to debug. Well. Strangely, the solution worked after that. So Microsoft did some tricks while deploying. So I searched and called some people, yes on sunday. And telling me that Visual Studio 2010 is deploying asychronously. Yeah I knew that, but after a minute and some conversation telling that Powershell is deploying synchronously. Well that the trick I thought. So I decided to help my self out with some times, running the admin jobs, etc.
Even that didn’t worked out.
Go debugging old fashioned style: disabling Web and Site scoped features in the onet.xml.
After the first Web Feature (Deploying some List Instances and List Definitions) disabled the solution worked by powershell. I didn’t have a clue, but ohh well, I decided to change the ordering of the feature. Instead of List Definitions first, I decided to set the List Instances first. And you know what, It worked.
After enabling the Web Feature again, I could run the New Site creation perfectly.
SharePoint 2010: (pilot , poc) Sites, webs, contentdb’s, what you should(n’t) do
by mysticslayer on Oct.28, 2011, under SharePoint 2010, SharePoint Foundation
Before I begin my blog I will thank everyone who thought this allready over and made it available thru all types of conferences worldwide.
First of all, this is my own comment about how to do work around with Sites, Webs, content database, etc. This is my own opinion based on what I’ve learned the last years and my based on my own experience combined with the experience from others.
So, let’s start with an example which causes me to write this blog:
A mid-size company started of with a simple pilot of SharePoint 2010. This pilot was to discover how SharePoint works, and does it fit within the organization. We agreed before we started to start all over again when the company decided to go further with SharePoint. Well after an half year the company decided to go further with SharePoint, but yet the pilot environment was allready promoted to production before we could started all over again.
Allright I thought, when everything is ok, and we don’t have any issues regarding the environment we can do that, because the physical as the logical architecture was future proof designed. Multiple Content Databases, multiple site collections, etc. The only thing we had to was give some servers more memory. That’s all.
I had installed, configured and designed the infrastructure, so I knew that kind of issues can happen, when a pilot environment will be promoted as a production environment. I wasn’t committed when others had the intranet designed with sites,templates, etc for the Pilot. But well, I’ve made some critical decisions in the infrastructure, but maybe I forget to mention it correctly. My bad.
In februari I was asked to go further with the environment, and we attached Reporting Services, Datawarehousing, etc. No issues there.
But now, when the point arrives we grow larger and larger, and when I checked the databases it was all good, because all databases where used. But then I saw one big problem. Yes, they didn’t use the Site Collections I’ve made in the start, but created just sub SPWebs. Ouch, yes here we go.
So, now we have to migrate 25 GB of subwebs to one of the Site Collections I created at the start. Well. it takes days to do it well, everything you have done in the early stages are allready critical in the organization, so you can’t make mistakes. Everything has to work as before when your migrated. Well convert to SPSite is one hell of task to do.
I think I’ve tested the migration over and over again. Used the information given by Gary Lapointe, and went further with it. Came up with more then 257 errors. Well okay, that isn’t much, but it doesn’t tell the errors you’ll get functional. Yes functional!!
Every site, list, workflow, CQWP has to be tested. And I mean, really tested if it works as before. I can tell you, I have to replace every CQWP, some lists are getting corrupted, content types are missing, list pages are gone, pages are not behaving as they should.
So before you decide to start of with a pilot think as a production site, because it will help you a lot and other a lot. SharePoint 2010 is scalable, ensure that your sites are scalable as well. Think scalable act scalable.
Do’s
Don’ts
Restore Site SharePoint 2010 issues with site collection owners
by mysticslayer on Sep.27, 2011, under SharePoint 2010, SharePoint Foundation
We’ve had some multiple issues regarding the Site Collection owners, and we had to fix these in a fashioned time. After restoring we had the issue that we couldn’t change the primary and secondary site collection Administrators. So it was difficult where the bug was for us. But it wasn’t a bug.
After a new fresh install of the SP farm we still had these problems… so we had to search it out. After a long search it seemed that the UserAccountDirectoryPath was the issue. When the User Account Directory Path is filled in the table [dbo].[AllSites] of your content database you can do what you want, but you can’t change the owners.
So we had to remove the UserAccountDirectoryPath: Set-SPSite -Identity “http://site” -UserAccountDirectoryPath “”
And voìla it was fixed. With two Quotes it removes the UserAccountDirectoryPath. You have to this allways if you’re restoring your Site Collection to another farm.
Restoring SharePoint databases with other schema (SharePoint 2010)
by mysticslayer on Aug.17, 2011, under SharePoint 2010, SharePoint Foundation
I just started out today to restore some Content Databases to test out my new created features on my development environment, to check if everything works as planned. But yet, I’ve figured out that I had some issues creating and deleting sites.
So I checked the ULS logs and nothing to see, I checked event viewer and also there no errors containing the message which I had: “Supported method not found” or something in that other.
Well I remember when I installed Service Pack 1 of SharePoint Server 2010 and tried to remove a site I had the same message. This was related to some bug or something. So I installed June CU Refresh and that worked perfectly. Well in this case I had both installed, so that shouldn’t be the problem.
So I checked the status of my Content Databases and what I noticed was that the schema version of the database wasn’t the same version as June CU Refresh. And the message was that I could update. Also the strange notice is that my Content Databases aren’t updated when you restore a database and attach it to SharePoint.
So what I did was run with powershell the following script:
$contentdb = Get-SPContentDatabase | Where-Object {$_.Name -match "WSS_ContentDB" }
Upgrade-SPContentDatabase -Identity $contentdb
Voila, content database is getting updated.
Reporting Services 2008 R2 Service Pack 1 with SharePoint 2010 Integration
by mysticslayer on Aug.14, 2011, under Reporting Services, SharePoint 2010, SharePoint Foundation
Today was the day I could install Service Pack 1 for Reporting Services 2008 R2 at a customer which has SharePoint 2010 with Reporting Services 2008 r2 integrated. Before Service Pack 1 we had alot of performance issues with Reporting Services. It didn’t perform while the hardware was more then sufficient. Sometimes it took more then 30 ms to load a simple report.
Today I installed the Service Pack 1 for Reporting Services, and it didn’t take alot of time to install it. Even while it is virtualized.
I installed the following updates:
- SQL Server 2008 R2 Service Pack 1
Also what I did is installing the following features from the SQL Server 2008 R2 Service Pack 1 Feature Pack:
- SQLSERVER2008_ASADOMD10.msi
- SQLSERVER2008_ASAMO10.msi
- SQLSERVER2008_ASOLEDB10.msi
- SqlCmdLnUtils.msi
- SharedManagementObjects.msi
- PowerShellTools.msi
All are installed on the server which runs SharePoint 2010 and Reporting Services 2008 r2.
After reboot. I checked the performance again to check if it installed correctly without any errors. I did, SharePoint Server ran, and started some reports. While it took the same time to run the Reports like before I took the time to install some more from the feature pack.
I installed the SQL Server 2008 Native Client on each server running SharePoint. When you run the prerequisite installer it installs also the SQL Server 2008 Native Client. So when it was done, I rebooted the servers which had these updates.
When the SharePoint Server cames up, I ran the rsSharePoint.msi from the Feature Pack on every server in the SharePoint farm.
Run the installer like this: msiexec /i rsSharePoint.msi skipca=1
It checks if the addin is installed, and asks if you want to update the Package. Of course, yes.
It takes about 30 seconds to install and it is done.
Now I started SharePoint and checked the Reports which I ran before, and the performance increased more then I could imagine. Even SharePoint reacted more snappy as before. It looks like Microsoft made some major performance increasements on the Native Client and the Reporting Services Add-In for SharePoint.
My advice: install it!
SQL Server 2008 R2 Service Pack 1 is released (SharePoint info)
by mysticslayer on Jul.30, 2011, under maintenance, Reporting Services, SharePoint 2010, SharePoint Foundation, sql server, Update
So after some time Microsoft just released there first Service Pack for SQL Server 2008 R2. This package contains alot of improvements regarding to performances for Analysis Services.
You can download SP1 here: http://www.microsoft.com/download/en/details.aspx?id=20302
Also when you’ve running SharePoint Server 2010 with Reporting Services integrated you should update your Reporting Services to the latest Service Pack. Also an important notice to this, you should also download the SQL Server 2008 R2 SP1 Feature Pack to accomplish some other improvements.
You can download SP1 Feature Packs here: http://www.microsoft.com/download/en/details.aspx?id=26728
When you’ve downloaded the Feature Packs you should also install the following components to all SharePoint Servers:
- rsSharePoint.msi
- sqlncli.msi
- SQLSERVER2008_ASADOMD10.msi
The first one is the SQL Server 2008 r2 Reporting Services Add-In for SharePoint Server 2010
The second is the SQL Server Client 2008 which you also have to install when you install the prerequisites for SharePoint Server 2010.
The third is also a component which is used in the prerequisite for SharePoint Server 2010.
There was an error in the callback content and structure
by mysticslayer on Jun.16, 2011, under iis, Internet Information Services, SharePoint 2010, SharePoint Foundation
I ran today in this message in the SiteManager.aspx of SharePoint Server 2010: there was an error in the callback content and structure
So allright, I checked the search engines and did find some answers regarding this problem, but you know what. When restart your IIS server on your Web Front End the message doesn’t go away. Hmm odd, how could that be, well I figured out that it does a call back to another server, in my case it was one of the other SharePoint Servers in the farm. After resetting this server it removes the message and everything works fine again.