Note: I seriously recommend you look into the PNP.PowerShell module instead of SPPS (now SPCSPS) for any CSOM PowerShell, however the code is still available for reference if needed
I have seen some small confusion with SPPS and the background requirements? needed for it to run - So I have built an extensible set of Virtual Machines for me to further investigate this
So……….
Basically if you are Running any of the older Systems Windows XP Server 2003 or Vista then unless you update to at least PowerShell v2 then unfortunately SPPS will not be able to run.
This is down to the method for reusability and management where SPPS is run using the Module framework instead of the older style Snapin framework. This has a lot more benefits as this allows IT Admins to auto deploy these without an additional Program installation. It also allows IT users to grab updated versions as they are released and can be used across a variety of different systems - There are even ones out there for Twitter, Facebook & Yammer.
Personally I am really enjoying using PowerShell v4 which can be installed as part of the Windows Management Framework v4 for your OS - Remember this is a Client-Side tool so you do not need to run this on a server.
However the point in this Post is to show you the First steps as required to get “Up and Running” with SPPS so that you can achieve the results that you need.
So firstly if you are reading this I’ll assume that you have already downloaded SPPS and have the module files stored to a directory of your choice.
If not the Download link is SPPS - Download
The module files can be stored in one of the PowerShell default Directories of which you can find more information about them in this Post by the Scripting Guy or you can use a location of your own.
Hey, Scripting Guy! How Can I Install Windows PowerShell Modules on Multiple Users’ Computers?
Ok so now we have that out of the way what do we need to do now.
Firstly we need to open a New PowerShell window (or PowerShell ISE - which is what I will be using throughout this example post) - Remember here to ensure that if you are running a 64 bit version of Windows that you haven’t opened the x86 version of PowerShell or the ISE as this is a crucial item going forward.
Once we have done that we will then import the Module as seen below - I try and keep a SP folder in the Root of my C Drive and that is where we will be importing the Module from in this case - however this would be different for you if you have it in your User Directory.
Ok so the Module has imported - Remember that when a Command is Successful you typically get no output displayed - so I have stuck to this as not to add further level of Complexity.
Now we have Imported the main SPPS module you can run (Get-Command -Module spps).count to see how many functions are available to you.
As you can see below there are 85 functions currently available
To see all the Functions you would run Get-Command -Module spps - It is important to remember that SPPS is still evolving so there will likely be many more additions to this as time goes along and this is a useful way to see what can be achieved with SPPS as time goes on.
Ok so we have imported the SPPS Module and now what do we need to do to get SPPS working with either our On-Prem or Online Instances. Well out of the box with Windows there is no ability to connect to a SharePoint Site with PowerShell so we need to ensure that we have the correct Dll’s (Dynamic Link Libraries) so that PowerShell can understand our commands to connect to SharePoint.
To do this we will fun a function called Test-SPPS and in its current form it will check if you have the Dlls installed and if not will open Internet Explorer to the correct Download links for the Client Redistributables for each version.
Please note that I intend to Update this to provide some choice input as I am aware not everyone will have a need for 2010 2013 and SharePoint Online dlls installed on their system.
Once you have installed the needed dlls you can run the Test-SPPS function again and as you can see in the below screen shot this is now telling me I am ready to connect to SharePoint 2010 2013 and SharePoint Online
So now we will need to perform the connection to the SharePoint Online site which in the below sample I will connect to a Test CSOM site in my Tenant and i will be passing a PowerShell Credential to this as I am accessing from a different domain. For more information about PowerShell Credentials please see this article which does a good job of explaining the different levels of security with PowerShell Credentials Secure Password with PowerShell: Encrypting Credentials - Part 1
However you can also use the following parameters OnlineUsername, OnlinePassword or you can also leave it blank as long as you specify that IsOnline is 1 (which is Boolean for True)
I will also in the near future do another blog post on Credentials and some of the better practices available to use when storing passwords (preferably not in plaintext) as the below example is not a recommended scenario but is there to show you what you can do.
You can also connect to a SharePoint Online Site and not provide any Credentials in which the Initialize-SPPS function will prompt you for them as shown below
To connect to On-Prem this is even easier if you are connecting from a Domain Joined machine and are logged in as a Domain User and you can access a SharePoint Site as you can just connect with a much simpler command - Please note that Initialize-SPPS defaults to load the SharePoint 2013 Dlls (as I expect that this is becoming more common than 2010) so if you are running 2010 then you will need to add -Is2010 1 to the line as shown below as well
Once connected you will see that there has been 3 new Variables created in PowerShell for use throughout your session with a brief description of what these are for.
And that is all that is needed to be able to Connect to a SharePoint On-Prem or Online Site Collection. The ability to provide a Credential allows for you to perform any needed “Admin” tasks like you may already do just via Web Browsers - However this is limited to the Site Collection that you connect to.
If you have any Questions feel free to leave a Comment or message me on Twitter or Yammer and if you aren’t already a member of the Office 365 Network then request to join it as there are some amazing discussions going on in there and its not just SharePoint related either.