Tuesday, February 2, 2016

PowerShell to upload a file into multiple sites under Project Web App (Office 365)

This is a powershell script custom written to upload an Excel report to multiple Project Online sites, but you could easily customize it to suit your own purposes. The same method works on Office 365 and SharePoint Online sites.

Prerequisites:
You will need to install the SharePoint 2013 client components on your client machine. I am running it on Windows 7 so I am actually using the PowerShell 64 bit version and 64bit client components.

 # Load SharePoint Client  
 Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"   
 Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   

I am using the newest version on Project online, hence the 16 hive. 15 hive works as well!

SP2010 C# CSOM: Update Created and Modified dates and author

Tested on SharePoint 2010 only. I wanted to have something that could run on a client machine that could help update metadata for a folder or file in a list / document library.

This is a console application written in C#. Obviously, to do something in SharePoint 2010 automation, you will need to download the SP2010 foundation and install some runtime components.

(Or if you are feeling lazy, just copy Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll and reference them in your project).

To make this piece of code work, you need to know the ID of your list/folder item. There are other methods of retrieving based on URL.

Related Posts Plugin for WordPress, Blogger...