CHunky Universe of Vigourous Astonishing SHarepoint :)

Category Archives: PowerShell

Count lines of code with PowerShell

Today I got a question:

How many lines of code are there in our SharePoint solution?

After a little search, I found that PowerShell is really a nice tool to count lines of code:

I wanted to count lines for different types of code:

  1. Code Behind written in C#, the files have .cs file extension
  2. JavaScript code (except jQuery, angular or knockout frameworks)
  3. PowerShell files (.ps1 and psm1)
  4. Xml files (all the SharePoint .xml files)

Here is the powershell code that counts lines of code:

# go to the solution folder
cd <solution directory>

#count lines in .cs files
ls -include *.cs -recurse | select-string . | measure | select count

#count lines in our .js files
ls -include *.js -recurse `
    -exclude *min.js, jquery*, _*, jsrender*, CamlBuilder*, knockout* `
  | select-string . `
  | measure `
  | select Count

#count lines in our powershell scripts
ls -include *.xml -recurse | select-string . | measure | select count

#count lines in our powershell scripts
ls -include *.ps1, *.psm1 -recurse | select-string . | measure | select count

Just a curious fact, I can’t tell you how many lines of code we have in our solution, but I can reveal the proportions. If I used the flexible box model in css3, it would look like this:

lines of code

There are as many lines of code written in javascript as it is in C#. The main reason that for the big js code base are the SharePoint hosted apps. The PowerShell scripts are as big the javascript code base. Xml files are 4 times bigger than C# code, and it is even bigger than the sum of all lines of code written in C#, JavaScript and PowerShell. It isn’t strange that xml is dominating, almost everything in SharePoint is defined in xml.

Fortunately, there are less cases where you have to write raw xml in Visual Studio 2012/2013 and SharePoint 2013.

How does it look in your project? What language is dominating in your SharePoint project?

scriptcs and SharePoint. How SharePoint can benefit?



Last Saturday I attended Leetspeak. Among many awesome speeches and presentations I discovered scriptcs.


scriptcs lets you write C# code directly in the console, or execute scripts written with just your favourite editor. Please see more about it on the site. What I thought during Justin Rusbatch’s session at Leetspeak:

Can we use scriptcs in SharePoint?

Technically there is no limitations in SharePoint for scriptcs. Any .NET code can be registered, imported and invoked in a console or in a standalone script. Here is the simple code for instantiating a site collection and disposing it:

#r Microsoft.SharePoint;
using Microsoft.SharePoint;
var site = new SPSite("http://dev");

The code above does not do anything, it is just there to demonstrate how you can register the SharePoint assembly (“Microsoft.SharePoint”) and import it into the script:

using Microsoft.SharePoint;

The example shows even that you in scriptcs no longer need the necessary “boilerplate” (compared to a console application): namespace, Program, Main()… You can just directly write your code.
The rest is the same as in a C# application. The code samples for scriptcs can be any code written in C# for SharePoint, code from custom console applications, from feature receivers, you name it. So my next question is:

How can SharePoint development benefit from scriptcs

I can think about these advantages with scriptcs in SharePoint:

  • Less need of PowerShell. As a developer you can use one language for creating SharePoint solutions and server configurations.
  • You don’t need to rewrite your C# code to PowerShell. It saves time. Often one can see two solutions: one for C#, one for PowerShell, example.
  • You can freely move code from feature receivers to scripts, like timer job installation, without rewriting code, example.
  • You can use scriptcs to discover the SharePoint API, site columns, sites, fields and so on. PowerShell can be used as well. But scriptcs lets you use the same syntax. PowerShell is much different. It is not case sensitive. It often doesn’t throw NullReferenceException, it just doesn’t output anything. So if you use PowerShell as an exploratory tool, then you still will need to verify it in a C# code to verify, that your code works. With scriptcs you can directly copy the code from console directly to your code solution.

Of course, if there are advantages, then it must be some disantvantages.

Shortcomings of scriptcs in SharePoint?

I have found these shortcomings

  • Missing powerful cmdlets for SharePoint (special “shortcuts” for configuration steps of SharePoint like New-SPWeb, Set-SPEnterpriseSearchService…)
  • Missing native functionality in PowerShell for parsing xml, importing and exporting to csv and xml, a very easy way to read and write files on disk.
  • There are already tons of PowerShell scripts written for SharePoint in companies and in the community. Mixing a huge amount of PowerShell with little scriptcs can increase complexity.
  • scriptcs is still new. It is not adopted by Microsoft and maybe will not be approved in your project.

So what do you think about scriptcs and SharePoint?

Would you use scriptcs in your SharePoint project? Leave a comment or send me a tweet.

Set IE Proxy Server with PowerShell

Today just a quick one-liner tip for PowerShell.  Use this script to set a proxy server in IE Settings. I got the inspiration from Aymeric’s blog:  Scripting : Toggle proxy server in IE settings with PowerShell:

sp AutoConfigUrl "" `
   -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

By the way sp is just alias for Set-ItemProperty cmdlet:

This corresponds these settings in IE (Tools – Internet Options – Connections – Lan Settings):


It can be useful if you have want to automate this.

A quick guide to configuring the Loopback check

Great tutorial how to configure the loopback check on a dev machine. Exactly what I needed for a month ago. Pity that this article came after that. 🙂

Here is the command to disable it completeley:

# Disable Loopback check #
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword


Update: A free tool is available that does all this for you in a GUI: Loopback Check configuration Tool released – free download

Hi dear friends!

401.1 Access denied…
If you try to access your newly created web application with a real nice FQDN or NetBIOS name and you end up getting a 401.1 Access denied…

Even after adding the site to the local intranet zone in IE…
Even after beeing prompted 3 times and filling in the correct credentials…
After setting up your Search to crawl you sites in a small farm whith crawl and web services on the same server…

You check and doublecheck your credentials, you add yourself as the farm admin, you try logging on with the farm account, but nothing…still 401.1…

I know this has been written about many times Before, but some things seem to still be missing…
Now everyone seems comfortable with the sparse description on how to ‘add…

View original post 756 more words

AutoSPInstaller: error while stopping the default web site in IIS


During an installation with AutoSPInstaller on my development machine I ran into a strange issue. I got the following error:

System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.IIS.PowerShell.Framework’ or one of its dependencies

I haven’t found any other people having the same problem with the AutoSPInstaller, but I found a similar report on another forum: Maybe I am the only one who gets this error in AutoSPInstaller, if not it can be useful to write the solution down.

The error occurs when the default web site in IIS is stopped. For some reason Get-WebSite cmdlet throws an exception the first time you invoke it, but not the second time.

To get it working I followed the tip from the and wrapped the Get-Website code in a try-and-catch, where the same cmdlet was in try and in catch. This line:

$defaultWebsite = Get-Website | Where-Object {$_.Name -eq "Default Web Site" -or $_.ID -eq 1 -or $_.physicalPath -eq "%SystemDrive%\inetpub\wwwroot"} # Try different ways of identifying the Default Web Site, in case it has a different name (e.g. localized installs)

becomes this code (the lines in try and catch are identical):

    $defaultWebsite = Get-Website | Where-Object {$_.Name -eq "Default Web Site" -or $_.ID -eq 1 -or $_.physicalPath -eq "%SystemDrive%\inetpub\wwwroot"} # Try different ways of identifying the Default Web Site, in case it has a different name (e.g. localized installs)
} Catch [System.IO.FileNotFoundException]{
    $defaultWebsite = Get-Website | Where-Object {$_.Name -eq "Default Web Site" -or $_.ID -eq 1 -or $_.physicalPath -eq "%SystemDrive%\inetpub\wwwroot"}

With this fix I was able to run the whole AutoSPInstaller script. My development machine was a fresh installed Windows Server 2008 R2 SP1 (without any updates).

Leave a comment if you run into the same issue. If so, I’ll try to send a patch to the AutoSPInstaller code.

Update 2013-06-06

This issue was reported to AutoSPInstaller at codeplex and closed as “self-resolved”.

PowerShell: Copy an entire document library from SharePoint 2007 to disk

For a while ago I needed to copy all files from a document library within a SharePoint 2007 site to the hard drive. So I didn’t need to copy files from SharePoint to SharePoint so I couldn’t use the stsadm -o export command or Chris O’Brien’s nice SharePoint Content Deployment Wizard. I came across the SPIEFolder application which should work with SharePoint 2007 and 2010. It has a site on codeplex:, but neither the binary nor the source code can be downloaded from there. After some searching I found the binary in the author’s skydrive. The fact that the source code was not available seemed as an disanvantage because I could not know what code was run. Nevertheless I tried it out and it didn’t work:

spiefolder -o export -url "http://dev/Documents" -directory c:\tolle\Documents –recursive

I got the following error:

The Web application at http://dev/Documents could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

So I wrote my own code to copy the documents. To write a console application feels so yesterdayish, so it is written in PowerShell. Even if there are no PowerShell snapins for SharePoint 2007, you have access to the entire Server Object Model, the only thing you have to do is to load the SharePoint assembly:


Then you can instantiate all SharePoint objects like in C#, but in a PowerShell way:

$site = new-Object Microsoft.SharePoint.SPSite("http://dev")
$web = $site.OpenWeb()

You can even download a module for emulating cmdlets: Get-SPWeb, Get-SPWebApplication and Get-SPFarm, written by Natalia Tsymbalenko ( to get started or just to find some inspiration.

I have created a ps1-script which only does one thing – it copies an entire document library to disk. Much of inspiration to structure the script comes from “Delete-SPListItems” (

Here it is: Pull-Documents.ps1

    Use Pull-Documents to copy the entire document library to disk
    This script iterates recursively over all directories and files in a document library and writes binary data to the disk
    The structure is kept as in the Document library
    It is mainly written for SharePoint 2007, but it works even in SharePoint 2010
    Pull-Document -Url http://dev -Library "Shared Documents"
    Name: Pull-Documents.ps1
    Author: Anatoly Mironov
    Last Edit: 2012-12-03
    Keywords: SPList, Documents, Files, SPDocumentLibrary
#Requires -Version 1.0
[Parameter(Mandatory=$true)][System.String]$Url = $(Read-Host -prompt "Web Url"),
[Parameter(Mandatory=$true)][System.String]$Library = $(Read-Host -prompt "Document Library")

$site = new-object microsoft.sharepoint.spsite($Url)
$web = $site.OpenWeb()

$folder = $web.GetFolder($Library)
$folder # must output it otherwise "doesn't exist" in 2007

    Write-Error "The document library cannot be found"

$directory = $pwd.Path

$rootDirectory = Join-Path $pwd $folder.Name

if (Test-Path $rootDirectory) {
    Write-Error "The folder $Library in the current directory already exists, please remove it"

#progress variables
$global:counter = 0
$global:total = 0
#recursively count all files to pull
function count($folder) {
    if ($folder.Name -ne "Forms") {
        $global:total += $folder.Files.Count
        $folder.SubFolders | Foreach { count $_ }
write "counting files, please wait..."
count $folder
write "files count $global:total"

function progress($path) {
    $percent = $global:counter / $global:total * 100
    write-progress -activity "Pulling documents from $Library" -status $path -PercentComplete $percent

#Write file to disk
function Save ($file, $directory) {
    $data = $file.OpenBinary()
    $path = Join-Path $directory $file.Name
    progress $path
    [System.IO.File]::WriteAllBytes($path, $data)

#Forms folder doesn't need to be copied
$formsDirectory = Join-Path $rootDirectory "Forms"

function Pull($folder, [string]$directory) {
    $directory = Join-Path $directory $folder.Name
    if ($directory -eq $formsDirectory) {
    mkdir $directory | out-null

    $folder.Files | Foreach { Save $_ $directory }

    $folder.Subfolders | Foreach { Pull $_ $directory }

Write "Copying files recursively"
Pull $folder $directory


I have tested this script in SharePoint 2007 and 2010. It works. Let me know if you find this useful or have some suggestions.

Run web.config-dependant code in PowerShell

PowerShell is a great tool. It helps in SharePoint administration and tasks automation. Today I needed to provision a webpart on many similar pages. This third-party webpart’s constructor instantiates a dataaccess service and uses a connectionstring which is stored in the web.config file. So the webpart creation failed until I found a way to load the configuration into powershell.

First you can create a simple file powershell.exe.config, put it into $pshome (C:\Windows\System32\WindowsPowerShell\v1.0). In that file you can specify the connectionstring in the same way like in the web.config (or app.config). But it is not secure: the connectionstring can be changed in the future, and you really don’t want to copy your connectionstrings around. So there is a better way: Check out Ohad Israeli’s blog post about how a configuration file can be bound dynamically in a .net assembly: Binding to a custom App.Config file.

In PowerShell you can do the same, all we need is to modify the syntax: StackOverflow: Powershell Calling .NET Assembly that uses App.config:

[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $config_path)

In SharePoint the web.config file resides in:


So include this in the script which invokes web.config dependant code:

$config_path = "C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config"
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $config_path)

The ability to bind the configuration file dynamically can be even helpful in another part of the SharePoint world – timerjobs. The timer jobs are executed by owstimer.exe. This service has an own configuration file: {hive}\BIN\OWSTIMER.EXE.CONFIG If the timer job configuration shares connectionstrings or appSettings with web.config, it should be theoretically possible to bind the web.config to owstimer. Leave a comment below if you find this information useful.

Create SPGroup in PowerShell

Thanks to Ryan for sharing powershell functions. I used New-SPGroup which I altered. Now You can define which permissions will be given to the new group. You can even create groups without default users. Here it comes:

function New-SPGroup {
	Use New-SPGroup to create a SharePoint Group.
	This function uses the Add() method of a SharePoint RoleAssignments property in an SPWeb to create a SharePoint Group.
New-SPGroup -Web http://intranet -GroupName "Test Group" -OwnerName DOMAIN\User -MemberName DOMAIN\User2 -Description "My Group" -Role "Read"
	This example creates a group called "Test Group" in the http://intranet site, with a description of "My Group".  The owner is DOMAIN\User and the first member of the group is DOMAIN\User2 and adds "Limited Access".
	C:\PS>New-SPGroup -Web http://intranet -GroupName "Test Group" -OwnerName DOMAIN\User -MemberName DOMAIN\User2 -Description "My Group" -Role "Read"
	This example creates a group called "Test Group" in the http://intranet site, with a description of "My Group".  The owner is DOMAIN\User and the first member of the group is DOMAIN\User2 and adds "Read" access.
	Pay attention to the role definition names. They must be provided in the language of your site.
	Name: New-SPGroup
	Author: Ryan Dennis, Anatoly Mironov
	Last Edit: 2012-11-05
	Keywords: New-SPGroup, spgroup, permissions
#Requires -Version 2.0
	$SPWeb = $Web.Read()
	if ($SPWeb.SiteGroups[$GroupName] -ne $null){
		throw "Group $GroupName already exists!"	

	if ($Role) {
		$roleDefinition = $SPWeb.RoleDefinitions[$Role]
		if (!$roleDefinition) {
			throw "Role Definition $Role doesn't exist!"

	if ($SPWeb.Site.WebApplication.UseClaimsAuthentication){
		$op = New-SPClaimsPrincipal $OwnerName -IdentityType WindowsSamAccountName
		$owner = $SPWeb | Get-SPUser $op
		if ($MemberName) {
			$mp = New-SPClaimsPrincipal $MemberName -IdentityType WindowsSamAccountName
			$member = $SPWeb | Get-SPUser $mp
	else {
	$owner = $SPWeb | Get-SPUser $OwnerName
		if ($MemberName) {
			$member = $SPWeb | Get-SPUser $MemberName

	$SPWeb.SiteGroups.Add($GroupName, $owner, $member, $Description)
	$SPGroup = $SPWeb.SiteGroups[$GroupName]	
	$roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($SPGroup)
	if ($Role) {
	return $SPGroup


Disclaimer: This post and function is 100% taken from the book by Gary Lapointe and Shannon Bray entitled “Automating Microsoft SharePoint 2010 Administration with Windows PowerShell 2.0.”

This post goes hand in hand with my recent post called “Retrieve SharePoint Groups using PowerShell.”  In that post, we used a simple PowerShell Function to retrieve an SP Group and return the object in our command window.  In this function, we’re going to take the work a step further – we will use our function to create a new SharePoint Group.

Again, I have taken the code from Gary and Shannon’s book – the only addition I have made is comment-based help.  Since I intend to use these functions, I like to have help so I can go back and see examples and things like that.

The function provided in the book is very nice, it consists of…

View original post 39 more words

Creating custom powershell cmdlet


I need to to activate a feature in PowerShell and specify some properties. Simple? Yes. Possible? No. In the default Enable-SPFeature cmdlet you can’t specify any properties:

Enable-SPFeature –Identity "b5eef7d1-f46f-44d1-b53e-410f62032846" -URL http://dev

We can of course easily add properties when activating features in onet.xml:

<!-- Publishing Resources -->
<Feature ID="AEBC918D-B20F-4a11-A1DB-9ED84D79C87E">
  <Properties xmlns="">
    <Property Key="AllowRss" Value="false" />
    <Property Key="SimplePublishing" Value="false" />

So I went to SharePoint StackExchange and asked the question. Then I realized: the standard Sharepoin API doesn’t support this neither. The methods of SPFeatureCollection which have SPFeatureProperties as parameter are internal. So the only way is to use Reflection like Hristo Pavlov (2008) and Yaroslav Pentsarsky (2010) suggest. So why not to try to create a cmdlet?


I want to create a custom cmdlet: Enable-SPFeatureWithProperties. It should look like this:

$properties = @{"Test" = "SPLENDID" }
Enable-SPFeatureWithProperties `
      –Identity "b5eef7d1-f46f-44d1-b53e-410f62032846" `
      -URL http://dev `
      -Properties $properties

The cmdlet code will be written in C# and published on github. It is a part of my project called sp-lend-id and like all other parts in sp-lend-id it will have a Chuvash word as its name: Taprat (/taprat/ meaning “Enable” 🙂 )


First I create a simple cmdlet just to get started. Then I test the reflection code to activate a feature with properties. Then, if this works, I will bring the pieces together and create my cmdlet.

Simple cmdlet

The best cmdlet tutorial (text, images, code and videocast) is created by Saveen Reddy. I just followed his sample. I created a new class library project and a class for the demo cmdlet: Get_DemoNames.cs.

By the way, if you don’t have th powershell dll as Saveen Reddy describes, add manually the reference to the csproj-file:

<Reference Include="System.Management.Automation" />

Build and test the cmdlet:

Activating the feature

Create a very simple Feature and Feature Receiver which takes properties and does something with them, like Yaroslav suggested:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
	var web = properties.Feature.Parent as SPWeb;
	if (web != null)
		var allow = web.AllowUnsafeUpdates;
		web.AllowUnsafeUpdates = true;
		if (properties.Feature.Properties["Test"] != null)
			web.Title = properties.Feature.Properties["Test"].Value;
		web.AllowUnsafeUpdates = allow;

After deploying this feature we can create a simple console application to test the reflection code. First, the extension for SPFeature to be able to invoke the internal methods:

public static class SPFeatureExtensions
    public static SPFeature ActivateFeature(this SPFeatureCollection features, Guid featureId, Dictionary&lt;string, string&gt; activationProps)
        var propCollConstr = typeof(SPFeaturePropertyCollection).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)[0];
        var properties = (SPFeaturePropertyCollection) propCollConstr.Invoke(new object[] { null });
        foreach (var key in activationProps.Keys)
            properties.Add(new SPFeatureProperty(key, activationProps[key]));
        return ActivateFeature(features, featureId, properties);
    private static SPFeature ActivateFeature(this SPFeatureCollection features, Guid featureId, SPFeaturePropertyCollection properties)
        if (features[featureId] != null)
            // The feature is already activated. No action required
            return null;
        var type = typeof(SPFeatureCollection);

        // now we have to get "AddInternal" Method with this signature:
        //internal SPFeature AddInternal(Guid featureId, Version version, SPFeaturePropertyCollection properties, bool force, bool fMarkOnly, SPFeatureDefinitionScope featdefScope)

        var param = new[]
                            typeof (Guid), typeof (Version), typeof (SPFeaturePropertyCollection), typeof (bool),
                            typeof (bool), typeof (SPFeatureDefinitionScope)
        var addInternal = type.GetMethod("AddInternal", BindingFlags.Instance | BindingFlags.NonPublic, null, param, null);
        if (addInternal == null)
            // failed to find the method
            return null;
        var result = addInternal.Invoke(features, new object[] { featureId, null, properties, false, false, SPFeatureDefinitionScope.Farm });
        return result as SPFeature;

There are some changes compared to Yaroslav’s code:

  • The testing if feature is enabled happens without internal Get Method, just by (features[featureId] != null)
  • The internal “Add” method now is called “AddInternal”
  • The parameters which have to be passed to the internal add method are changed, too.

I found the signature of the “AddInternal” using Reflector.NET 6:

internal SPFeature AddInternal(Guid featureId, 
				Version version, 
				SPFeaturePropertyCollection properties, 
				bool force, 
				bool fMarkOnly, 
				SPFeatureDefinitionScope featdefScope)
    return this.AddInternalWithName(featureId, null, 
            version, properties, force, fMarkOnly, featdefScope);
Testing the code in a console application

Just a few lines of code to test and debug the code:

static void Main(string[] args)
	using (var site = new SPSite("http://dev"))
		using (var web = site.OpenWeb())
			var activationProps = new Dictionary
				{{"Test", "Title changed by feature in activation"}};
                          new Guid("b5eef7d1-f46f-44d1-b53e-410f62032846"), 

The pre-condition is that the test feature is deployed, then it works:

Running it in Powershell

Now, when we know the code works, we can test it in powershell. We create three params:

[System.Management.Automation.Parameter(Position = 0, Mandatory = true)] 
public string Identity;

[System.Management.Automation.Parameter(Position = 1, Mandatory = true)]
public string Url;

[System.Management.Automation.Parameter(Position = 2, Mandatory = false)]
public System.Collections.Hashtable Properties;

The third parameter is Hashtable because the main “dictionary” object in PowerShell is Hashtable. So we must convert the passed hashtable into a Dictionary:

private Dictionary<string, string> GetProperties()
    var dictionary = new Dictionary<string, string>();
    if (Properties != null)
        foreach (var key in Properties.Keys)
            dictionary.Add((string)key, (string)Properties[key]);
    return dictionary;

Then the only thing we have to do is to copy the code from the Main method in console app into the ProcessRecord method:

protected override void ProcessRecord()
    var properties = GetProperties();
    using (var site = new SPSite(Url))
        using (var web = site.OpenWeb())
            var features = web.Features;
            var id = new Guid(Identity);
            features.ActivateFeature(id, properties);

Now we can rebuild the solution and run the powershell by importing the module:

$p = @{"Test" = "Tjena" }
Enable-SPFeatureWithProperties -Identity "b5eef7d1-f46f-44d1-b53e-410f62032846" -Url "http://dev" -Properties $p
Creating PSSnapin

So the cmdlet is completed. There is one thing left which I want to try: creating pssnapin which one can add in an easy way to a powershell session. To create a pssnapin we have to create class in the project and extend it from PSSnapin. This class just has some properties: Name, Description and Vendor:

public class TapratInstaller : PSSnapIn
    public override string Name
            return "sp-lend-id.taprat";

    public override string Vendor
            return "Anatoly Mironov";

    public override string Description
                "This includes an experimental cmdlet to activate sharepoint features and specify custom properties";

To install the pssnapin, run these commands in powershell as Administrator:

Set-Alias installutil $env:windir\Microsoft.NET\Framework64\v2.0.50727\installutil.exe
installutil C:\code\sp-lend-id\taprat\cmdlet\sp-lend-id.taprat\bin\Debug\sp-lend-id.taprat.dll

Pay attention that we have to run installutil.exe from Framework64, not Framework. Otherwise the pssnapin won’t be accessible.

After the pssnapin has been installed we can see it by running:

Get-PSSnapin -registered

Now all we have to is to add the newly created pssnapin and run the commands:

Add-PSSnapin sp-lend-id.taprat
Get-DemoNames -Prefix "Hello "

And the desired:

$properties = @{"Test" = "SPLENDID" }
Enable-SPFeatureWithProperties `
      –Identity "b5eef7d1-f46f-44d1-b53e-410f62032846" `
      -URL http://dev `
      -Properties $properties

Of course, in order this to work, we have to deactivate our test feature first. Then the cmdlet activates our test feature which only updates web title in this experiment. It works. Splendid!


The code can be found on sp-lend-id project’s code repository on github:


This code is just a lab code for experimenting and learning purposes. Don’t use it in production environments unless you test it yourself. As Per Jacobsen pointed in his answer on Sharepoint StackExchange, the internal methods can vary in different releases and patches of SharePoint, which we can see here (Yaroslav’s code can’t be run anymore), and it can break your solution deployment.

Out-Gridview in PowerShell

Did you know that we can pipe the output from PowerShell into a graphical GridView? I have used PowerShell for one year and only now I discovered this nice feature. You can add filter criteria, you can filter by typing in a textbox:

Other useful output cmdlets
  • out-file
  • out-clip
  • out-null
Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...


SharePoint på ren svenska