Configuring SharePoint through PowerShell

Hello

I am trying to configure my SharePoint 2013 site through PowerShell, but I am having a hard time connecting to it. I've opened SharePoint Online Management Shell, made a new PSSession with this command:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri URL HERE -Credential $UserCredential -Authentication Basic -AllowRedirection
After this, I imported the session that I created.

This is where I get stuck. I want to add myself as a SPShellAdmin (I don't know if I am by default, as an Office 365 administrator) but it returns the error "Add-SPShellAdmin : The term 'Add-SPShellAdmin' is not recognized as the name of a cmdlet, funtion, script file or operable program etc.."

My final goal is to run this command succesfully:

Export-SPWeb -Identity <SiteURL> -Path <Path and File Name> [-ItemUrl <URL of Site, List, or Library>] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]

What would be the correct way to run this, from scratch?

Thanks in advance

Best regards,
Jannik

February 19th, 2015 9:57am

Why are you using the Online Management Shell, which is meant for use with Office 365 with SharePoint 2013?

For on-premises PowerShell you need to use the SharePoint Management Shell which is available on any of your SharePoint servers but is a pain to run off box.

Free Windows Admin Tool Kit Click here and download it now
February 19th, 2015 10:08am

Is this on-premises or Office 365?  If its on-premises then you are using the wrong tool.  You need to use regular PowerShell not the Online Management Shell.  If its SharePoint Online that yo are working with then you will not be able to run the command you want to run.  SharePoint Online doesn't support Export-SPWeb or Add-SPShellAdmin.

here's an article on how to use PowerShell in an On-Premises environment:

https://technet.microsoft.com/en-us/library/ee806878.aspx

and here's one on SharePoint online:

https://support.office.microsoft.com/en-us/article/Introduction-to-the-SharePoint-Online-Management-Shell-c16941c3-19b4-4710-8056-34c034493429?CorrelationId=c68d129e-23bf-473a-a58e-dd157f40f6d6&ui=en-US&rs=en-US&ad=US

February 19th, 2015 10:13am

I thought this was the right thing to use, considering the name saying SharePoint Online - Guess I was wrong.

I do not have access to the server running our SharePoint - we have a paid service, for someone else to run it. Does that mean, we cannot configure it through PowerShell?

Free Windows Admin Tool Kit Click here and download it now
February 19th, 2015 10:17am

Hello

I have no idea, what the difference is. We are using Office365, and the SharePoint is a menu in our "Office 365 administration portal", so I guess its Office365.

February 19th, 2015 10:19am

Then you're right, that is the right shell to use.

What you've hit is something we all do at some point. The SharePoint online environment, aka Office 365, doesn't allow the same level of control that on-premises SharePoint does. In fact you can't use the Standard PowerShell commandlets at all on it.

This list shows you all the cmdlets available to you: https://technet.microsoft.com/en-us/library/fp161364.aspx

You can't and don't need to add yourself as a shell admin, but there's bad news; you can't easily do the Save Site As Template process as it isn't accessible with those cmdlets.

It can be done as Chris O'Brien describes here but it's far from as easy as you'd like:

http://www.sharepointnutsandbolts.com/2013/12/Using-CSOM-in-PowerShell-scripts-with-Office365.html

Free Windows Admin Tool Kit Click here and download it now
February 19th, 2015 12:15pm

Thanks a lot for your help Alex, it has been great so far! 

One last question for you though - is there a way to back-up an entire document library, to a local server? We want to store all of our documents on out SharePoint, but if we cannot access SharePoint for some reason, we want to be able to restore all the files. Is that possible with Office 365?

February 20th, 2015 2:26am

Yes. There's probably a dozen different ways to do it though.

The simplest is to use OneDrive for business, that should let you 'sync' the library to a local machine.

Beyond that you could create a script that copies the data down on a regular basis, or you could consider something more substantial/clever if needs be.

Free Windows Admin Tool Kit Click here and download it now
February 20th, 2015 3:14am

A script is exactly what I was thinking. Something that copies the data down ever hour for example, so we have a chance of restoring data, if we cannot connect to SharePoint.

I'm not the biggest fan on OneDrive for business. We use that already, but I've noticed, that it takes up space on the actual hard drive itself. That'd result in everyone in our company needing 5tb hard drives, most of those being SSD's, which is... not affordable. :-P

If I had a synology NAS in the basement, would I be able to make a backup schedule, which downloads all files onto the local drive on the NAS, and how would I do that? Or can I automaticly upload everything to something like Amazon Glacier?

February 20th, 2015 3:23am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics