Microsoft is releasing a new Powershell script to allow customers to upload files directly from a file share to a SharePoint document library. In addition, the script will allow files that have metadata to carry that metadata into SharePoint. The script was developed by the group responsible for the Windows Server 2008 R2 File Classification Infrastructure and supports both SharePoint 2007 and SharePoint 2010. If you are not familiar with the File Classification infrastructure, it allows organizations to assign classification metadata to files on a Windows Server 2008 R2 file server. For more on File Classification infrastructure see one of my earlier posts on this topic.
The business reason behind the script is that a lot of organizations still have thousands of documents on server file shares. At some point these organizations will want to migrate those files into SharePoint to make them more available for collaboration, and to facilitate management of the files. FCI allows organizations to assign metadata to all the files on a file server, and this new script will enable transfer of the files and the associated metadata into SharePoint.
The combination of FCI and SharePoint overcomes a major hurdle in using the full power of SharePoint -populating files with metadata. Metadata allows users to filter and search information in SharePoint in a much more powerful way, especially with SharePoint 2010 features such as navigation hierarchies and key filters. Many customers say they can get their files into SharePoint, but they have no idea how to assign metadata to all these files. FCI along with this new script allows organizations to overcome this hurdle.
Getting metadata into SharePoint provides benefits for user search and file disposition and can also be used to strengthen security via products like our Metadata Security for SharePoint.
The new script is called FciSharePointUpload.ps1 and is available from Microsoft at this download site.
The script provides two options:
Option 1: Upload a file to a SharePoint Library - SharePoint 2007, SharePoint 2010.
FciSharePointUpload.ps1 –file <file path> -url <target site> -libPath <relative library path> [-name <target name>] [-sourceAction {keep|delete|url}] [-targetAction {overwrite|skip|fail}] [-propertyAction {copy|ignore}] [-user <user name> -password <password>]
Option 2: Upload a file to SharePoint using the official file web service that is coupled with a content organizer (e.g.: Record center) – SharePoint 2010 only.
FciSharePointUpload.ps1 –useOfficialFileWebService –file <file path> -url <target site> [-name <target name>] [-contentType <content type name>] [-sourceAction {keep|delete|url}] [-propertyAction {copy|ignore}] [-user <user name> -password <password>] [-additionalProperties] <property list>
The parameters are as follows:
- file: path to the file to upload (required)
- url: URL to the SharePoint site (required). Example: -url ”http://sharepoint/sites/mariant”
- libPath: relative path to the document library within the site (required), Example: -path ”Shared Documents”
- name: name of the target file (optional). If not specified, it defaults to the source file name as specified by the “file” argument. Example: -name Test.docx
- contentType: name of the content type to use for the document (optional). If not specified, defaults to “Document”
- sourceAction: indicates how to handle the source file after a successful upload (optional) - 1) keep - leave the file in place (default) 2) delete: delete the file;3)url: replace the file with a shortcut to the uploaded document’s URL
- targetAction: specifies how to handle existing destination documents (optional) - 1) overwrite, replace (default) , 2) skip: leave existing version and continue , 3) fail: return error
- ropertyAction: specifies FCI property transfer mode (optional) - 1) copy: transfer properties (default) , 2) ignore: do not transfer properties, let SharePoint choose defaults
- user: user name to use for authentication (optional). The argument is ignored if “password” is not specified.
- password: password to use for authentication (optional). The argument is ignored if “user” is not specified.
- additionalProperties: list of extra properties to use for the document (optinal). The argument is followed by a space-separated list of strings. Each group of three strings is interpreted as the name, type and value of the property to add, in this order. The list size must be a multiple of three. These additional properties are always used, regardless of the propertyAction argument value. Example: -additionalProperties PII Boolean True BusinessImpact Choice High
Here is an example I created. I created a file share called "Merger". I then tagged all the files in this share with metadata property called CorpClassification, and a value of "CONFIDENTIAL" using FCI (you can't actually see the metadata in the file system).
I then created a column called CorpClassification in a SharePoint library called Merger, and using the script I copied these three files into the SharePoint library. As you can see the metadata has been transferred with the files.
Be careful when creating the property and column type in FCI and SharePoint. These have to match up as per the script requirements, or the script will not work. In my case, the FCI property was of type "Choice", this means I had to create a column of type Choice - Checkboxes in SharePoint. If I tried to define any other column type (e.g Choice - Dropdown) the script will not work.
Great post. I enjoyed reading thanks.
Posted by: Property in Turkey | 02/11/2010 at 04:28 PM
Very good post. I have been searching for this post since many days. Now I have implemented the same for my site.
Posted by: Term Paper | 02/18/2010 at 01:54 AM
I got it to work! Thanks for the help!
Posted by: Jared Stenzel | 03/01/2010 at 10:22 PM
Hi there, thx for the post..would you know if this script will copy the created by, create date, last modified by and last modified date over from the file share to SharePoint (2010)?
Thx
Posted by: Ken | 10/28/2010 at 12:06 PM
Hi Ken,
Yes it should bring over those properties.
Posted by: Charlie | 11/12/2010 at 09:56 AM
Can this be used with Windows server 2003 and sharepoint 2007?
Posted by: Debbie | 05/25/2011 at 01:17 PM
Hi Debbie,
No, this only works with Windows Server 2008R2 as it depends on the FCI components which only became available in that release.
Posted by: Charlie | 06/10/2011 at 02:26 PM