Getting Started: The Basics of Using PowerShell with SharePoint

I’m a SharePoint guy, and certainly no PowerShell expert. I know enough PowerShell to get things done in SharePoint from time to time. I can often go months without using PowerShell and talking to colleagues I don’t think I’m alone in the SharePoint community.

So if you are just starting out with using PowerShell to do something with SharePoint, or it’s been a while and you need a refresher on the basics then you’ve come to the right place.

Before we get started I’m writing this article based on SharePoint 2013 running on a Windows 2012 server.

The ground rules

1) Run your PowerShell scripts from the SharePoint server itself

It is possible to run PowerShell against a remote SharePoint server rather than on the server itself, but it requires some setup on the SharePoint server side and let’s face it, it’s not basic. If you need to do it you need to be searching for “Remote PowerShell in SharePoint”.

2) Use Windows PowerShell ISE (not SharePoint Management Shell)

PowerShell needs to be executed/run at a PowerShell Console or PowerShell Window – this window looks like a standard Command Line window and I don’t find it too inviting.

Instead of the SharePoint 2013 Management Shell, I use the Windows PowerShell ISE.


Why? It’s like comparing Visual Studio with Notepad. The ISE is an environment for developing PowerShell scripts that gives you nice syntax highlighting, debug with breakpoints, intellisense and more. It’s more like a development environment than a command line. I think you’d agree it looks slightly more advanced.


3) Ensure the SharePoint PowerShell snapin is loaded

When using the “SharePoint 2013 Management Shell” (the ugly black one) it automatically loads a “snapin” which is basically a PowerShell extension that gives you a series of commands for working with SharePoint objects. When you use the Windows PowerShell ISE it has no idea of SharePoint, so you need to load the SharePoint snapin manually. The simplest way to do this is just to add the following code snippet to the start of all your scripts.

if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
      Add-PSSnapin Microsoft.SharePoint.PowerShell


4) Save a script to file before you try to run it

Windows PowerShell ISE will have trouble running a script if you haven’t saved it to disk yet. PowerShell scripts are saved as files with a .ps1 extension.


5) Talk to SharePoint via the SharePoint PowerShell Cmdlets

Here’s a reference of all the SharePoint 2013 PowerShell Cmdlets you can use to work with SharePoint.


Your first script

Pre-flight checklist:

  • Start Windows PowerShell ISE
  • Add code snippet for loading the SharePoint snapin
  • Save the script as a .ps1 file


You can now start cutting and pasting examples from the internet and modifying them to work with your environment. The following 2 lines get a handle on the SharePoint website at the URL http://vs-server12 and then output the ID of the website.

To run the script and see if it work, click the Run button.


Any output from running your script is shown in the output window below the script editor.


You’re on your way, just remember you can only access the SharePoint server on which you are running your scripts. Accessing remote SharePoint servers is possible but you need to do special magic stuff to make that happen Smile


If you encounter an error along the lines of:

Get-PSSnapin : No Windows PowerShell snap-ins matching the pattern “Microsoft.SharePoint.PowerShell” were found.

You’ve ignored ground rule 4 and the pre-flight checklist by forgetting to save your script before running it (yes, I still do this too).


How to fix issue with opening Visual Studio solution from by moving it to

This problem arises if you were using Team Foundation Services (TFS) Online while it was still in preview. You will be accessing TFS on a URL such as: A recent change has been made to TFS Online that prevents you opening solutions using this URL. When you try to open an existing solution (that you have already synced down to your development machine ) you will see the following error message in Visual Studio:


Attempting to “Go Online” with the solution, or disconnect from TFS and reconnect using the same address will result in a security credentials prompt that accepts your credentials but just sits there blank. BTW trying to login to the URL in IE also results in this blank page behavior, in Chrome it gives a slightly better redirect error.


What Microsoft want you to use instead is the address instead:

This is simple if you just want to access TFS in a browser. Simply use the new address, but how do you get Visual Studio to start using the new URL to connect for a solution you already have on your dev machine?

Here’s the process that’s worked for me across Visual Studio 2012 and 2010.

Remove the existing TFS Connection from The Team Explorer



Now Add a TFS Connection using the URL



Open the TFS Source Control Explorer now you are connected using the new address



Select the solution folder for the solution you have synced to the local workspace on your development machine. Right click the solution folder and select the Get Specific Version… option from the context menu.



Ensure you check the option to “Overwrite all files even if the local version matches the specified version”. This will effectively pull all files for the solution from TFS again even if there has been no change made to the files. This has the side effect of fixing the binding of the files so that after the sync the files will now be bound to instead of



Once the sync has completed you should see the following message:



Click Yes, and you will get a dialog letting you know of any offline changes.



That should be job done. Your Solution Explorer should now show the TFS icons indicating the source control state of all the files and you’ve now left the URL behind.

Other links referencing this issue:


How to bulk upload/copy a folder structure and files to SharePoint

So you’ve got a bunch of files nicely arranged in a folder structure sitting on your computer or a network drive that you want to copy up to a SharePoint library and preserve the directory structure. On the surface this is a daunting task as you can’t just give SharePoint your folder structure and tell it to do the work for you, so what are your options.


Option 1: Manually via SharePoint IU

Recreate the folder structure in SharePoint and upload the files via SharePoint UI in batches doing a multiple file upload to one destination folder at a time. Not much fun for anyone, but it can be done.


Option 2: Commercial Tool

Try a 3rd party tool. Yes they will probably cost you but will get the job done and probably with a few extra bell’s and whistles like applying metadata to SharePoint columns during the process. Some of the key companies to take a look at would be:


Option 3: Open Source Tools

There are some open source projects going around that claim to handle these types of bulk uploads, here’s a couple that look interesting:


Option 4: Script it Yourself

PowerShell is an awesome way to get things done quickly in SharePoint, I’ve written these scripts in the past that show you how to create folders and how to upload documents to SharePoint. With a bit of extension and effort you could roll your own scripted solution.


Option 5: Explorer View

The old ‘Open Library in Explorer View’ option in SharePoint may get you out of trouble if the directory structure and number of files is fairly small. Simply use the Explorer View to open the SharePoint library up in a Windows Explorer window and then copy/paste or drag/drop into the Window and the magic will start to happen


Option 6: OneDrive for Business

Now this is my preferred option for getting the job done, and the reason for writing this blog post! To achieve this one, browse to your library in SharePoint and click on the sync button to have the SharePoint library sync’d via OneDrive to your local machine.


After the sync has completed the SharePoint library (and it’s content including any folder structure) is now represented as a folder structure that you can easily get to through Windows Explorer.


Now it’s just a matter of copy/paste or drag/drop your local folder structure (that you want to copy to SharePoint) into this folder in Windows Explorer. Here is my folder structure I want to copy up to SharePoint.


So I can just copy the “My Folder Structure” folder and paste it into the SharePoint sync library location. This is super quick because it’s just copying between 2 locations on your local hard drive.


Now the real goodness happens. OneDrive will sync the entire folder structure including any content files up to SharePoint in the background. You will notice that the folders and files you have just pasted have a tiny icon in the left corner. This will display a green tick when the item has been created in SharePoint. This is awesome, your computer is still free to use, there’s no lockup. If you need to shutdown before the sync is finished, it will just pick up from where it left off. OneDrive’s mission in life is to keep your local folder in sync with the SharePoint library, and it will work tirelessly in the background to do this.

Another powerful advantage this method has over many of the other options I provided earlier is that it will work with Office 365 which you just can’t reach some of those other methods.

Now my disclaimer before I get people throwing virtual rotten fruit at me. I’m not suggesting you use this method to move an entire network drive to SharePoint. Yes, I advocate you should take the opportunity to clean up the data on your network drives and not just move the problem to SharePoint. I also believe in the use of metadata to classify content rather than using folders. Having said that, there are valid instances when you do need to perform an upload of many files and preserve the folder structure in SharePoint and I think the OneDrive approach is a pretty cool tool to add to your arsenal.

SharePoint PowerShell How To: Create SharePoint List Items (in Root and in Folders) for Load/Performance Testing

SharePoint PowerShell How To Series - Foreword

I often find myself scratching around the local drive of my development machines for remnants of PowerShell scripts to generate list & libraries in SharePoint with all sorts of different folder hierarchies to test the performance of code I’m working on to ensure it scales well once the folder & item counts start getting up to high numbers. So rather than keep scratching I’m going to start posting my scripts as I create and use them so I can find/reuse them later on and someone else might find them useful as well. I’m sure they won’t work under all scenarios and situations (and they are not designed to). They are just quick scripts that serve a specific purpose to me at the time and you may be able to tweak to fit your needs.

Create list items in the root of a custom SharePoint list

Script description: Creates 10,000 list items in the root folder of the “OnePlace License R7” list of the site located at the URL “vs-server38”.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

# Script settings
$webUrl = "http://vs-server38"
$listName = "OnePlace Licenses R7"
$numberItemsToCreate = 10000
$itemNamePrefix = "License "

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

# Create desired number of items in subfolder
for($i=1; $i -le $numberItemsToCreate; $i++)
$newItemSuffix = $i.ToString("00000")
$newItem = $list.AddItem()
$newItem["Title"] = "$itemNamePrefix$newItemSuffix"
write-host "Item created: $itemNamePrefix$newItemSuffix"

#Dispose web

Create list items in a folder of a custom SharePoint list

Script description: Creates 10,000 list items in the “OnePlaceDocs” folder of the “OnePlace License R7” list of the site located at the URL “vs-server38”.

Note: this assumes you have already created a folder called “OnePlaceDocs”in the list.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

# Script settings
$webUrl = "http://vs-server38"
$listName = "OnePlace Licenses R7"
$subFolderName = "OnePlaceDocs"
$numberItemsToCreate = 10000
$itemNamePrefix = "License "

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

# Get handle on the subfolder
$subFolder = $list.RootFolder.SubFolders.Item($subFolderName);

# Create desired number of items in subfolder
for($i=1; $i -le $numberItemsToCreate; $i++)
$newItemSuffix = $i.ToString("00000")
$newItem = $list.AddItem($subFolder.ServerRelativeUrl, [Microsoft.SharePoint.SPFileSystemObjectType]::File, $null)
$newItem["Title"] = "$itemNamePrefix$newItemSuffix"
write-host "Item created: $itemNamePrefix$newItemSuffix"

#Dispose web

Others articles in this series:

What’s the difference between a UX designer and a UI designer?

I love this infographic, quickly sums up the differences (and similarities) between a UX designer and a UI designer.

[Click the image to see full size]


Solving the “Boot Failed. EFI SCSI Device” error when installing Windows 2012 Server on Hyper-V

I’ve installed Windows 2012 server on a few Hyper-V images in the past but ran into an error that looked unfamiliar. I created my Hyper-V machine, configured it with a dynamic hard drive, added a DVD and mounted the Windows Server 2012 ISO making sure the DVD drive was top of the boot order and started it up.


I was then presented with a black screen an the error message:

Boot Failed. EFI SCSI Device.


Here’s the long winded explanation from the Senior Program Manager of the Hyper-V team (John Howard).

The short answer: It’s because the virtual machine was created as a Generation 2 machine rather than Generation 1.


To get past this error simply hold down a key as you start up the virtual machine. You’ll notice at the top of the error screen it says “Press any key to boot from CD or DVD…..” the issue is that it doesn’t wait for you to press a key, just make sure you have a key held down when it gets to this point and you should see the Windows Boot Manager prompt allowing you to boot to the DVD image.


Then hey presto you’ll get a successful boot to DVD and the Windows Setup window you expected.


A remote SharePoint Navigation tree control designed to scale to large Enterprise environments

The SharePoint Navigation tree (for remotely browsing/navigating SharePoint) is a central component in the OnePlaceMail product. It is used in all major operations such as Save to SharePoint, Open from/Insert from SharePoint, Preview SharePoint content, Managing favorite SharePoint locations. Being able to quickly find the right location in SharePoint, directly from desktop applications, is one of the key reasons OnePlaceMail has been adopted so openly into organizations. Core to this capability is the OnePlaceMail Navigation tree.

Dynamic browsing

The primary purpose of the tree is to allow you to browse your SharePoint environments.


Here’s the features we baked into the tree at a low level to ensure we could build a scalable tree for enterprises.

  • Support multiple SharePoint servers in the same tree (accessing them all at the same time)
  • Support any mix of SharePoint servers at the same time (2007, 2010, 2013, SharePoint Online, Office 365, on-premises or hosted)
  • Zero configuration – just give the tree a URL to SharePoint. The tree will figure out what type of server it is and the best way to communicate with it. Those irritating things like security are also hidden away (if possible you just don’t see any security prompts). Worst case the tree will ask you to login if it needs credentials.
  • What a user see’s in the tree is driven 100% dynamically by SharePoint security.
  • All communication with SharePoint is done asynchronously (in the background). This means the tree is silky smooth and responsive, even if the SharePoint server isn’t.
  • Optimized client/server communication – minimum data payload and real-time loading at each level of the tree as nodes are expanded
  • Large SharePoint environments sooner or later come up against SharePoint throttling and threshold limits. We designed with these in mind (think libraries with thousands of folders or document sets)
  • Support for browsing over sites/libraries/folders where user only has read only access to allow saving of content into a lower level folder where user has contribute access

Advanced node filtering

As the SharePoint environment grows it is quite typical for a certain level of the tree structure to grow in line with some business process being modelled. Here are some examples:

If you create a site per project (or client) you end up with a lot of sites at a particular level in your SharePoint environment. Similarly you may end up with lots of libraries in a site, or the one we come across most frequently, a large number of document sets within a library.

For the user trying to find a location at this level, it creates a situation where they are forced to scroll through a long list to find the site/library/folder/document set they are looking for. What we have implemented in our navigation tree, is a type-ahead filter on any node in the tree. This will start filtering all nodes below by the characters as you continue typing. In the example below a document library is used to store legal matters. One document set is created for each legal matter, and this particular library has over 10,000 legal matters (document sets). As you can see in the screenshot, just by typing “77”, the legal matter document sets have been filtered from 10,000 to 10 (not bad for 2 keystrokes). We’ve also made the filter type configurable so it can perform a “starts with” filter or a “contains” filter. This filtering is available at all levels, on all node types in the tree so use it to filter a long list of sites or libraries as well and folders.



Recent locations

If you’ve been somewhere in SharePoint recently, then there is a good chance you’ll want to go back. The navigation tree will automatically remember recent locations so you can quickly get back to them. These recents aren’t just static locations, you can expand them and filter them just like any other node in the tree.



The organisation can only structure SharePoint in one single hierarchy (essentially in a tree). This one global structure of SharePoint rarely fits with how individuals see SharePoint. What we’ve done here is to allow a “My OnePlaceMail” area in the tree where a user can bookmark their own favorite locations from anywhere across any of their SharePoint environments. We’ve also given them the ability to create folders to organize and arrange these favorite SharePoint locations. What this delivers to users is the ability to setup a mini tree of SharePoint that reflects how they see SharePoint. This gives efficient access to just those areas of SharePoint that are relevant and removes the clutter of other areas of SharePoint. Similar to recents, these aren’t just static locations, you can expand them and filter them just like any other node in the tree.


Create New Folders and Document Sets

What good is a tree that doesn’t grow! Based on SharePoint settings and security you can simply create folders and/or document sets directly within the tree using the context menu on the tree node. This isn’t limited to a simple input for folder name. The screenshots below show the creation of a custom Legal Matter document set and completion of properties for the new document set (all dynamically read from SharePoint – zero configuration).



Search for locations rather than browsing

Sometimes the browse metaphor for navigating SharePoint just isn’t very efficient, rather than browse we have given the option to also use a search metaphor for finding locations in SharePoint, this works well in certain scenarios:

  • Large SharePoint environments
  • Areas of SharePoint where you are not familiar with the hierarchy structure
  • When you know the exact location in SharePoint and search is faster than navigating to it
  • Finding locations to save to
  • Finding a site collection (as site collections have different top level URLs you often cannot browse them, you have to know the top level URLs to begin with). If you create a new site collection per client/customer/project and therefore have a large number of site collection, being able to find the site collection quickly via search in the tree is brilliant
  • Finding locations across site collections

A key concept here is in the navigation tree we are searching for locations within SharePoint not content. To explain that a little bit, consider your conventional search via the SharePoint UI. This is designed for finding content e.g. documents, files. The navigation tree displays SharePoint hierarchy (or locations such as Sites, Libraries & Folders) not content. So unlike a normal SharePoint search for content, in the tree we are actually trying to find the location or container in which to store content or in SharePoint terms:

  • Site Collections
  • Sites
  • Lists
  • Libraries
  • Folders (within a list or library)
  • Document Sets (within a library)



Search scoping

The scope for the search is dynamic based on the selected location in the tree when the search is performed. For example, if you select the “Intranet” site collection in the tree, then only the “Intranet” site collection is searched. Likewise if you select a specific document library, then only that library is searched. This scoped searching works to restrict scope to a site collection, site, library, or folder/document set.

The converse of performing a search restricted to a scope is to perform a “farm wide search”. This performs a search across all site collections in the farm and as it returns locations it can be used to find site collections themselves.

Switch from search result to browse

The search feature for finding location works really well but what makes it simple awesome (just my opinion) is that we’ve allowed you to take a search result and then switch back to the browse navigation metaphor to explore that location further. This is really, really powerful. For example you may have a SharePoint environment where you create a new site per project and there are tons of these project sites scattered across multiple site collections. You can now do a simple search in the tree to find the site then drill down within the site to find a document library (which is actually where you would want to save or open files from).




The capabilities of the Navigation Tree make it scalable to fit any SharePoint environment from the very small to the very large and deliver a slick, modern, responsive interface to SharePoint. The tree control continues to evolve with each release of OnePlaceMail and we certainly have big plans to take it forward even further.

Download an evaluation of OnePlaceMail Enterprise and give the tree a go for yourself (it’s a client only 3 minute install)


This article was written based on OnePlaceMail Release 6.6 – read other highlights of this release

Leaving Las Vegas – SharePoint Conference 2014 (SPC14) Photos

As the SharePoint community disperses from Las Vegas after another awesome conference it’s time to digest the new information and figure out what that really means for you.

The takeaways for each person are probably different as we all use SharePoint in different ways, although there was one very prominent message being pushed…

Microsoft’s forecast: Very cloudy with a chance of on-prem meatballs

Microsoft was pushing the cloud first model very heavily, Office 365 will be getting all the new bells and whistles with on-prem maybe getting some of the new features down the track. Features that integrate the different services (e.g. Yammer/SharePoint/Exchange/OneDrive) would probably only be available in Office 365 where Microsoft can guarantee the compatible versions across the services and control passing user identity between the services and may never make there way to on-prem.

Attendee’s forecast: We are not ready/can’t move/don’t want to move to the cloud yet

This was the sentiment I was hearing on the booth. The reasons for not wanting to jump to the cloud (at the moment) were varied but most had understandable reasons. Microsoft has the potential to alienate a lot of the community and customers (possibly losing them to competitive products) if they take the big stick approach and try to force people into Office 365.

On a more positive note for on-prem customers, it was announced that there will be a new release of SharePoint (on-prem) in 2015.

The Venetian was an awesome location for the conference. Maybe it’s just me or maybe Vegas has slightly refined itself since the last conference but I thought the area of the strip near the Venetian had a better buzz about it and was just a nicer end of town. The Venetian itself was excellent with plenty of great options for eating and drinking. Anyone know a place that does a gourmet burger better than Vegas?

SPC14 was the conference that saw us announce the growth and re-positioning of our brand. OnePlaceMail has become one product of the larger OnePlaceEnterprise suite. Along with OnePlaceMail, the OnePlaceEnterprise suite contains the new products OnePlaceDocs and OnePlaceLive. This growth and shift was well received at the conference and I’m really looking forward to this new phase as OnePlaceEnterprise enters the market.

Thanks to all those who came up to see us at the conference and traded SharePoint stories. I hope you all enjoyed the conference and were able to walk away more knowledgeable at the end of the day.

Where and why to find me at the SharePoint Conference in Las Vegas (SPC14)




SPC is THE largest SharePoint Conference on earth, nowhere else will you find so many subject matter experts and people willing to talk SharePoint.

I encourage you to be brave and speak to the myriad of Exhibitors and Microsoft people at conference. The Exhibition Hall is a lot quieter outside of the peak lunch/break periods so if you’re in a session that’s not delivering what you hoped, head out and get an expert to yourself.

Why talk to me?
There’s only so many conversations you can squeeze in, my areas of interest include:

  • Overcoming user adoption issues with SharePoint deployments
  • Techniques for making SharePoint quicker and easier to work with from your desktop
  • Extending solutions you build on SharePoint to make them accessible from existing desktop applications without writing code!
  • Anything SharePoint and Mail related
  • SharePoint Site Mailboxes

Where to find me?
I’ll be presenting OnePlaceMail alongside 2 new products (OnePlaceEnterprise and OnePlaceLive) being launched at the conference. I’ll be spending most of the conference at the OnePlaceMail booth #2131 so please come up and say ‘Hi’.

Have a great conference and I hope to see you there.

SharePoint Conference 2014 Las Vegas – Essential Links


These are the essential resources I’ll be keeping my eye on as the SharePoint Conference 2014 in Las Vegas draws nearer.


The Official Site Conference Site

Goes without saying, this site IS the official conference site. Announcements, news and details released here are the real deal and your getting the information first hand.


SharePoint Conference Party Calendar #SPC14

Joel Oleson is keeping track of SharePints, parties, and events both official and unofficial. Joel’s party guidance in previous years has proven spot on so I hope he comes through with the good again this year!


Melalogix Best of Breed Awards and Gala 2014

This looks like it will be one of the largest unofficial parties. There’s limited tickets so keep your eyes and ears open on how to get your hands on a ticket for this one.


President Bill Clinton will deliver the keynote address at SharePoint Conference 2014

How often do you get to see an (ex) American President in the flesh? I won’t be missing the keynote, even if I’m more than a little lost of the connection between Bill and SharePoint!


The 2014 Microsoft Product Roadmap

My (obvious) tip is that the most significant announcements coming from Microsoft at the conference will be in relation to the 2014 product roadmap. Why wait for the conference? Take a look at this reference to see new updates and release expected soon or around conference time. Some details of what they include is already available. This may influence which sessions you decide to go to…


Collabshow Feed on all things SPC14

The Collabshow website has a page dedicated to all things SPC14. The website is run by Joel Oleson and is well worth keeping an eye on for news as the conference gets closer.


SPC14 Survival and Readiness Guide

Why start from scratch and try to think of everything yourself? People have already started putting together checklists and info packs on how to get the most out of the conference (even old guides from SPC12 are still quite relevant). This is one of the better one to emerge.


Get every new post delivered to your Inbox.

Join 72 other followers

%d bloggers like this: