maandag 28 januari 2013

Get all recycle bins filled with content.







To know in which sitecollection the recycle bin is filled.

Function GetallFilledRecyclebins($LogFile, $SiteUrl)

{
     Start-Transcript -Path $LogFile


     $sitecollection = SPSite($SiteUrl)

     foreach ($web in $sitecollection.AllWebs)

     {
        
Write-Host $web.Url + "->" +  $web.RecycleBin.Count

     }

     Stop-Transcript

}

GetallFilledRecyclebins c:\temp\log.log http://www.url.com

Get all version enabled lists







To search on all site collections manually to version enabled lists takes a lot of time.

So because of that i wrote a ps script.

Function GetAllVersionEnabledLists($LogFile, $SiteUrl)
{

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

Start-Transcript -Path $LogFile

$sitecollection = SPSite($SiteUrl)
foreach ($web in $sitecollection.AllWebs)
{
foreach($list in $web.lists)
{
if ($list.EnableVersioning -eq $true)
{
Write-Host ($site.Url +"-" +  $web.Title +"-"+ $list.Title + "->" + $list.EnableVersioning)
}
}
}

Stop-Transcript
}


Example : GetAllVersionEnabledLists c:\temp\log.log http://url 

dinsdag 22 januari 2013

Read ULS log with powrshell


When solving issues on a SharePoint environment. You need a lot of times take a look at the ULS logs of SharePoint. Instead of logging in on a remote desktop connection (RDC) you can create a file share of the log files folder of SharePoint.

With the next PowerShell script you can read the uls logs via the file share based on your Correlation ID.



Function Get-ULSLog ($correlationid, $timelimit = 30) {
                @("Server 1","Server 2","Server 3") |
                % {gci "\\$_\Name of the file share\*.log"} |
                ? { $_.LastWriteTime -gt (Get-Date).AddMinutes(-$timelimit)} | 
                import-csv -delim "`t" | ? {$_.Correlation -match $correlationid}
}


Get-ULSLog "Correlation ID" 30



Have fun, it will save a lot of time.

vrijdag 2 december 2011

Powershell & SharePoint

Yesterday i received an interesting blog item from my colleage which i wanted to share with you.

Hi All,

If you are thinking about creating a SharePoint environment with the help of our friend PowerShell, you will discover that almost everything is possible.

So let's create a  'User' (person/group) column :

### Add custom site column ###

$fieldXML = ' Name="myUser"
Description="name it"
Type=”User”
DisplayName="Add me to your list ..."
Group="Custom Columns"
Required="true"
ShowInDisplayForm="true"
ShowInEditForm="true"
ShowInListSettings="true"
ShowInNewForm="true"
List="UserInfo"
ShowField="ImnName"
UserSelectionMode = "PeopleOnly"
UserSelectionScope = "0">
'
$spWeb.Fields.AddFieldAsXml($fieldXML)

$spWeb.Update()

The column will appear in the 'Custom Columns'


Next thing, we will add this column to a content type :

### Add column to CT ###

$spColumn = New-Object Microsoft.SharePoint.SPFieldLink ($spWeb.Fields["Name"])

$Ct = $spWeb.ContentTypes["ContentType"]

$Ct.FieldLinks.Add($spColumn)

$Ct.Update()

Your site column was added to your content type ...


Enjoy PowerShell :-)

maandag 9 augustus 2010

vrijdag 19 maart 2010

How to : Encrypt / Decrypt sharepoint web.config file

When using security information in your config file. It's recommended to encrypt that part of the config file. Below you will find the steps how to configure sharepoint to use the encrypted web.config.


1) Add the next config part just under the config section of the web.config.



2) Encrypt the certain part of the config file.

aspnet_regIIS -pef "Section" "path"

3) Create an leycontainer.

aspnet_regIIS -pc "KeyContainerName" -exp

4) Add Application Pool user to the security of the key container.

aspnet_regiis -pa "KeyContainerName" "Application Pool User"


See also : Walkthrough: Creating and Exporting an RSA Key Container

dinsdag 5 januari 2010

Installing sharepoint 2010 prerequisites without an internet connection

Installing prerequisites

Most of the time developers need to install a developement environment on VMWare or with Hyper V. Most of the time there is no connection with the internet available. Because the normal installation of SharePoint 2010 needs to have an internet connection to install the prerequisites it's inpossible to install the prerequisites.

Below you will find a list with the prerequisites to install.

SQLClient

SyncFramework

MSChart

Powershell

Geneva Framework

Microsoft ADOMD.Net

woensdag 23 december 2009

Sub-folders vs Metadata – a Story About Resistance and Changing Jobs

There is always resistance by end users to go the metadata route instead of using sub-folders in their document libraries. Their arguments for staying with sub-folders have some validity when it comes to resistance to change though. People don’t like to change. Changing from sub-folders to metadata is like changing jobs.

More ........

Linked in iscussion

Using Business Connectivity Services in SharePoint 2010

Kirk Evans
One of my kids’ favorite books is called If You Give a Mouse a Cookie by Laura Numeroff─a children’s book based on the slippery-slope notion that if you give a mouse a cookie, he will ask for milk, realizing he is thirsty. When he drinks the milk, he will ask for a mirror, then some scissors, then a broom, then some crayons, and on and on, asking for a new item once he realizes the utility of the item he currently has.

This is how I see many users progressing along the adoption timeline with SharePoint: they begin slowly, uploading a few documents, and then progress to using workflows and forms and ultimately wanting to surface external data on their site. It isn’t until you see how easy one task was to accomplish that you decide to go for the next challenge.

It’s a common scenario: I have a portal, I have some external data, and I want to integrate that data into my portal in a meaningful way. Microsoft Office SharePoint Server 2007 (MOSS 2007) introduced the Business Data Catalog (BDC) to facilitate this exact scenario: make it easy to surface external data inside a portal experience. For example, you can create an XML definition file that defines the mapping between SharePoint and your external data so it can be rendered in a Web Part, used as a column within a list and even integrated into search.

When I show companies how they can use BDC to map to existing line-of-business applications, the light bulb usually turns on after I show search results that include people, documents, list data and data from their existing LOB system─all within the same set of results.

Even though the BDC in MOSS 2007 enabled connectivity to external systems, it was difficult to create solutions because of the lack of a designer. Furthermore, though BDC made it relatively easy to create read-only solutions that display data in the Business Data List Web Part, it was not so simple to create a solution that enabled users to make changes and write that data back to the external store.

Business Connectivity Services (BCS) in SharePoint 2010 is all about connecting to external data. BCS enhances the SharePoint platform’s capabilities with out-of-box features, services and tools that streamline development of solutions with deep integration of external data and services. BCS builds upon its BDC predecessor in the key areas of presentation, connectivity, tooling and lifecycle management. For example, in SharePoint 2010 it’s easy to create an external content type with SharePoint Designer, create an external list in SharePoint’s Web user interface and take the list offline into Outlook as a set of contacts. Also, you can make updates to contacts in Outlook that will cause the data in the external system to update as well.

More ......

zaterdag 12 december 2009

Sharepoint 2010 Beta - Records Management

SharePoint 2010 introduces new capabilities regarding Records Management. The most interesting feature, I think, is In-Place Records management (info at the end of this post) which makes it possible to declare documents as records without moving them to a Records Center. Records and documents live side by side in the site they were created in, and SharePoint 2010 makes it possible to apply different policies (i.e. retention schedules) depending if the item is a record or a document.

The Record Center site template is still available. It utilizes some new functionality like the Content Organizer to route incoming documents to the libraries of your preference. A new “dashboard” gives a record manager faster access to common tasks and to-do actions.

Holds (with discovery), audit and file-plan reports are also new or improved functionality to better control your records.

Other items than documents can also be declared as records in SharePoint 2010; wiki pages, blog posts, article pages among others.

This post gives an overview of two capabilities; Records Center and In-place Record Management. Functionality like Holds, File-plan and other Records management features will be covered in later posts.

The functionality described in this blog post may be changed substantially prior to final commercial release of SharePoint 2010.


Create a Records Center site
Simply create a Records Center by selecting the correct site template:

When creating a Records Center in SharePoint 2010, the following features are enabled:

Content Organizer

E-mail Integration with Content Organizer

Hold and eDiscovery

Metadata Navigation and Filtering

Offline Synchronization for External Lists

SharePoint Server Enterprise Site features

SharePoint Server Standard Site features

Team Collaboration Lists


The new look of the SharePoint 2010 Records Center:



The “Submit a Record” button let users upload (and add metadata to) documents. The documents will be added to the “Drop Off Library” and then moved to the correct library/folder according to the rules added by the records manager.

Note: Activate the “In Place Records Management” feature on the Site Collection level to fully take advantage of the Records Center. The feature has to be activated to mark incoming documents as records:



Create / enable Content Types
The Content Organizer uses Content Types (and related metadata) as criteria for where to move incoming documents. Content Types must therefore be created (or enabled) before routing functionality are enabled.

Create libraries for storing Records
I created a document library; “Contracts 2009” and added a rule “Contract” to the Content Organizer. When documents are submitted, the Content Organizer will move any documents related to the Content Type “Document” into the “Contracts 2009” library. You can create as many libraries/folders and content organizer rules you need to best control your records.

In my “Contracts 2009” document library, I went to Library Settings and enabled “Automatically Declaration”. Now, all documents added to the library are automatically flagged as records.:



Create Content Organizer rules
I added rules by selecting: Site Settings / Site Settings / Site Administration / Content Organizer Rules:



What happens if my target library doesn’t have the necessary Content Type enabled? I tried to create a rule which is using the Content Type “Dublin Core” as a criteria. I wanted all documents related to “Dublin Core” to be moved to the “Contracts 2009” library. As you can see from the message below, all target libraries also need necessary Content Types enabled for the Content Organizer to be able to move documents into the library.



Retention Schedule
Retention Schedule is, per default, enforced on the Content Types, but it is possible to define retention schedules on library/folder level too.

Retention schedule using Content Types
I went to Site Action / Site Settings / Galleries / Site content types (on Site Collection level), then I clicked on the content type “Document”.



Then i clicked on “Information management policy settings”, checked the “Enable Retention” and was given the choice of running different retention schedules on Non-Records and Records:



I chose to use a different retention schedule, and clicked “Add a retention stage for records…”. I was given the choice of setting different actions when the event fires.



It’s possible to add multiple actions, and each stage will occur one after the other in the order they appear on the page:



Retention schedule using Library/folder
Retention schedules are possible to configure directly on a document library. I went to my “Contracts 2009” library and selected “Document Library Settings. Under “Permission and Management” I clicked “Information management policy settings”. Here, I changed the source of retention by clicking on the “Change source”.

When choosing a different source a message will pop up, that basically says that you’re overriding the retention schedule at the Content Type level:



Then a form was presented, where I added my retention events and actions.

In-Place Records Management
A new capability in SharePoint 2010 is In-Place Records management. Instead of moving a document to a specific Records Center, you declare the document as a record and it will be handled as a record in the site it was created in. After the the document is declared as a record, it can have policies and restrictions different than when it was a document. The policies are added to either the Content Types or directly on the document libraries (see the Retention Schedule paragraph above).

Documents can be declared as records either manually or automatically.

Manual record declaration can be configures on Site Collection level and overridden in each document library. In Site Collection settings you have the following options on how declarations of records should be done:



When Record Declaration Availability is set to “Available in all location by default”, a new icon appears on the Ribbon:



A document will get a padlock added to its icon when declared as a record:



Again, you can override the record declaration availability on the document library level:



Automatically declarations of records is possible by checking the “Automatic Declaration” option in the document library settings.

Sharepoint 2010 Beta - Content Organizers

How many times have you gone into a company that needs enterprise document management for day to day activities? Typically you have grandiose plans to organize documents using content types. Best practice right?! No folders, hooray!? Users should love it right?! Only to discover that the people in the trenches see the added work of physically going to the appropriate document library as another "step" followed with "I don't have time for that".

SharePoint 2010 attempts to ease the pain of filing documents with a new concept called 'Content Organizers'. Basically sp2010 looks at rules of incoming documents and tosses them into a specified document library.

Let's enable this feature and set up some rules to see what Content Organizers can (and can't) do inside SharePoint 2010!

Assuming you are running as administrator on your website, go to Site Settings and click 'Manage Site Features' under 'Site Actions'.



Towards the top of the screen, Content Organizer should be sitting there with an Activate button.



(if you get a message indicating that you need another feature to be enabled, go to site collection features and enable either Office SharePoint Server Enterprise Site Collection features or Office SharePoint Server Standard Site Collections features)

Click on Activate, then click on 'View All Site Content' under the Site Actions menu or in the left hand navigation menu.

SharePoint 2010 creates a document library called 'Drop Off Library'. This is going to be the starting point for your future visitors. Save this address and move back to Site Settings.

In the 'Site Administration' section, Content Organizer Settings and Content Organizers Rules are now selectable options.



Click on Content Organizer Rules so that we can see what options are available. From here we can specify some fairly important configuration settings.

It is possible to force users into uploading documents to the Drop Off Folder. (no direct access to document libraries)
Email admins if documents do not satisfy any 'move' rules.
Versioning and preserve document context.

Lastly, in the submission points section, sp2010 presents a Web service URL. Save that URL in your notes, that actually gets important and will be discussed in a future blog post regarding workflows.

Going back to site settings, click on Content Organizer Rules.

Hopefully by now the ribbon control looks familiar. With the ribbon control on 'Items', click New Item.

If your site has existing Content Types, they will be available to be selected in the dropdown menu. Under 'Submission's Content Type' section, there is a conditions section that will allow you to enter more detail. This is not a required field, meaning it is possible to tell sp2010 to just move all items that are documents to a specified location. Here I like to specify my content types with a value.

At the time of writing (9/15/1009), 2010 allows the specification of six conditions.

In the 'Target Location' section, click on browse. Notice that all the document libraries listed exist in the current site.



So is it possible to move documents to another site? Is it possible to move documents to another site collection?

In the Target Location section, select the radio button 'Another content organizer in a different site'. The dropdownlist will display all of the options that you currently have to route this document elsewhere.



If you don't have any options here, it is because you haven't associated any content organizers to any send to connections. (The next post will discuss this process. )

At this point, you should be have a basic understanding of what a Content Organizer is, how to enable the feature and how to create rules. You also have witness to the difficulty of moving documents across sites or site collections.

Fortunately for us, Microsoft gave us a few workarounds for moving documents across site collections. It is fairly easy process. One option is out of the box, the other option involves SharePoint Designer 2010.

So, save that Web Service URL from the Submission Point section and come back to the next post when you are ready.

donderdag 5 november 2009

Access Denied when Activating Feature

When you following the Microsoft's Best practices for installing and set different application pool account for each application pool, you will get an error when activating a feature with webconfig modifications.

A quick work arround for this is to temporarly change the application pool account of the webapp from which you will activate the feature, to the same account as the central admin webapp.

This is because the central admin application pool account has specific permissions on stored procedures on the sharepoint_config database,which are required to run the update.

Links to the Best Practice Guides

Office SharePoint Server security account requirements

Installation guide for Office SharePoint Server 2007

maandag 22 juni 2009

Important information on Service Pack 2

When you have installed SP2 read the following important information.
 
 

Value Origin Site Definition

STS#0 Team Site WSS
STS#1 Blank Site WSS
STS#2 Document Workspace WSS
MPS#0 Basic Meeting Workspace WSS
MPS#1 Blank Meeting Workspace WSS
MPS#2 Decision Meeting Workspace WSS
MPS#3 Social Meeting Workspace WSS
MPS#4 Multipage Meeting Workspace WSS
WIKI#0 Wiki WSS
BLOG#0 Blog WSS
BAS#0 Business Activity Services Team Site MOSS
SPS#0 SharePoint Portal Server Site MOSS
SPSPERS#0 SharePoint Portal Server Personal Space MOSS
SPSMSITE#0 SharePoint Portal Server My Site MOSS
SPSTOC#0 Contents area Template MOSS
SPSTOPIC#0 Topic area template MOSS
SPSNEWS#0 News area template MOSS
SPSNHOME#0 News Home area template MOSS
SPSSITES#0 Site Directory area template MOSS
SPSBWEB#0 SharePoint Portal Server BucketWeb Template MOSS
SPSCOMMU#0 Community area template MOSS
_GLOBAL_#1 sitetemplate <- Can’t use this one! Just so you know it exists. MOSS

dinsdag 31 maart 2009

Sharepoint Feature: Variantion Flags Feature

Out of the box there is a control which displays the Variations you have specified. These variations are displayed in a dropdown list. On 90 % of the sites on internet the languages (variations) are displayed as Flags.

So I started a search on the internet to a web part which will display the language as flags.
I thought that I wouldn’t be the first who wanted this in his SharePoint application.
Put after a long search. I couldn’t find any web part. So I decided to develop it my self.


Out of the box variation feature


This variations feature

donderdag 29 januari 2009

Workaround : Ajax and publishing pages.

When you have configured SharePoint for use with AJAX you will see , when you deploy an AJAX web part and put this on a pages, that when running this page the web part will fire the events but not will render de web part.

The work around for this “bug” is to move the
<WebPartPages:SPWebPartManager ID="SPWebPartManager1" runat="server"/> just below the
scriptmanager tag in side the form tag.

Original:
<WebPartPages:SPWebPartManager ID="SPWebPartManager1" runat="server"/>
<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

Change it to:

<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<WebPartPages:SPWebPartManager ID="SPWebPartManager1" runat="server"/>

Then you will se the web part will be rendered after fire ring an event.

woensdag 3 december 2008

Sharepoint: Add or delete you configuration settings on feature activate / deactivated

When activating a feature you can add some settings to the web.config for example. Below you will see some code to add configuration settings.



Insert the next Code into the event FeatureActivated of your event receiver of your feature.

ConnectionString

SPSite site = (SPSite)properties.Feature.Parent;
SPWebApplication webApp = site.WebApplication;
SPWebConfigModification modConfig = new SPWebConfigModification("add[@name=\"name of connectionstring\"]", "configuration/connectionStrings");
modConfig.Owner = strOwner;
modConfig.Sequence = 0;
modConfig.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
modConfig.Value = String.Format("<add name=\"{0}\" connectionString=\"{1}\" providerName=\"{2}\" />", " name of connectionstring ", "connectionstring", ProviderInfo");
webApp.WebConfigModifications.Add(modConfig);
webApp.Farm.Services.GetValue<SPWebService>().WebConfigModifications.Clear();
webApp.Update();
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

Section

SPSite site = (SPSite)properties.Feature.Parent;
SPWebApplication webApp = site.WebApplication;
SPWebConfigModification modsec = new SPWebConfigModification("section[@name=\"name of section\"]", "configuration/configSections");
modsec.Owner = strOwner;
modsec.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
modsec.Value = String.Format("<section name=\"{0}\" type=\"{1}\" />", "name of section", "Type");
webApp.WebConfigModifications.Add(modsec);
webApp.Farm.Services.GetValue<SPWebService>().WebConfigModifications.Clear();
webApp.Update();
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();



Insert the folowing code in the FeatureDeactivating of your event receiver of your feature.

When you deactivate the feature all the entries which was made by the owner will be deleted.

Remove setting

SPWebApplication webApp = SPWebApplication.Lookup(new Uri(AbsoluteUrl));
if (webApp != null)
{
Collection<SPWebConfigModification> collection = webApp.WebConfigModifications;
int iStartCount = collection.Count;
// Remove any modifications that were originally created by the owner.
for (int c = iStartCount - 1; c >= 0; c--)
{
SPWebConfigModification configMod = collection[c];

if (configMod.Owner == strOwner)
collection.Remove(configMod);
}


// Apply changes only if any items were removed.
if (iStartCount > collection.Count)
{
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
webApp.Update();
}
}

maandag 1 december 2008

Sharepoint: Execute timerjobs immediately.

By using the STSADM operation gl-execadmsvcjobs, we can force the timer job to execute immediately.

With this STSADM operation we do not need to wait the timerjobs reached the schedule time.

stsadm -o gl-execadmsvcjobs

Sharepoint: Size limit of wsp file.

Today we had the problem that the size of the WSP exceeded the limit of the wsp Files. So when generating the WSP file inside visual studio the WSp file was split in two WSP files located on different locations.

There is a solution to disable the size limit of the wsp file.

Add the next code to the ddf file.

.Set CabinetFileCountThreshold=0
.Set FolderFileCountThreshold=0
.Set FolderSizeThreshold=0
.Set MaxCabinetSize=0
.Set MaxDiskFileCount=0
.Set MaxDiskSize=0

If you added this code to the ddf file. Visual studio will generate one wsp file.

Thanks to this blog We could solve the problem

donderdag 27 november 2008

Sharepoint: Enable Language Switching

Today someone at work pointed out that there was a switch control in SharePoint that allows user to easily switch between the different languages a page is available in. I hadn't heard from this already, so if you haven't either, now you've got no more excuses to say you don't!

Now what exactly does it do? Quite easy... If variations are enabled and there's a version of a certain page available in a different language, a switch will show up to easily switch between the different versions of the page. If your page only exists in English for example, the switch control won't show up.

But most importantly... How do you enable it? Well, that's easy too. All you need to do is follow some simple steps:

- Go to the ...\12\TEMPLATE\CONTROLTEMPLATES folder and open the VariationsLabelMenu.ascx file.

- Look for the line that's commented out. Remove the comment tags to enable the control. Here's the line you should comment out:

" IsCallbackMode="true" runat="server" />

- Now go to the Master Page you want to include the control in and make sure that it has the following tag at the top:

<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>

If this tag is on your Master Page and you've commented out the control, then the switch control should be showing right beside the links in the upper right corner of the Master Page. Now you can use this control and put it where ever you want to. If you want, you can also use it like this: