FCI SharePoint Upload PowerShell script

Windows Server 2008 R2 includes the File Classification Infrastructure feature set that provides insight into files to help manage data more effectively, reduce costs and mitigate risks by providing a built-in solution for file classification allowing administrators to automate manual processes with predefined policies based on the data’s business value.  FCI include file management tasks that allow IT administrators to automate tasks such as expiring stale data or migrating files from File Servers to SharePoint.  The FCI SharePoint Upload PowerShell script is built to work in conjunction with the FCI file management tasks (Customizing File Management Tasks) to automatically upload files and their classification properties to SharePoint.  This supports uploading any file type and if the SharePoint site have matching classification properties to the File Server, the script will set these properties accordingly.  For example: If a TIFF file is uploaded and the FCI property “Secrecy” is set to “High” then if the SharePoint library to which the file is uploaded contains a column for “Secrecy”, the script will set the “High” value for “Secrecy” for the uploaded TIFF file

The script support both SharePoint 2007 and SharePoint 2010:

Usage example: Creating a file management task that uploads all files that are marked as “Project=Apollo” and leave links pointing to the uploaded files

A few data points before we lay down the steps:

·         Address of the SharePoint site is http://contoso

·         Document library on that site called “Project Apollo”.

·         User “contoso\johndoe”, with a password of “up@load”, has the rights to contribute to the site.

Using the FCI snap-in (Customizing File Management Tasks)

1.       In the right pane, click on “File Management Tasks”.

2.       Click on “Create File Management Task…”

This will bring up the “Create File Management Task” dialog.

3.       In the “General” tab, fill in the fields in the dialog as follows:

a.       Task name example: “SharePoint Upload”

b.      Scope example: “C:\projects”

4.       In the “Action” tab select “Type: Custom”

5.       Fill in the rest of the fields as follows:

a.       Executable: “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”

b.      Arguments: -noninteractive -file c:\scripts\FciSharePointUpload.ps1 -file “[Source File Path]” -url “http://contoso” -libPath "Project Apollo" –sourceAction url -user contoso\johndoe -password up@load

c.       Run the command as: Local System

Note that we use the macro “[Source File Path]” to refer to the file to upload. Our command (powershell.exe) will be executed for each file in the defined scope and the macro will be replaced with the full path to the file. The script will be executed in the Local System context in order for it to be able to access the file management functions. Thus, it is necessary to specify the user name and the password that the script will use when uploading files to the site.

6.       In the “Condition” Tab add a condition such as “Project   Equal  Apollo”

7.       In the “Schedule” tab add a schedule on which you would like to perform the operation

Once you configured the task, you can also choose to “Run task now” and observer the results

SharePoint 2010 - Uploading files to a Records Center using the Official File Web Service

To make our file management task upload files to a SharePoint 2010 Records Center instead of directly to a document library, all we need is to modify our script parameters to use the “Official File Web Service” . Assume the Records Center contains a content organizer rule that redirects all submitted documents with “Project=Apollo” to the “Project Apollo” library.

You will need to have a content type in the records center that you want to assign to the uploaded files and contains the “Project” property

To do this, you would use the same file management task and just modify the script arguments (in 5.b above) to:

-noninteractive -file c:\scripts\FciSharePointUpload.ps1 -useOfficialFileWebService -file “[Source File Path]” -url http://contoso -contentType “Project File” -sourceAction url -user contoso\johndoe -password up@load”

Known issues with SharePoint 2010 Beta: When uploading files using the –useOfficialFileWebService switch, for Microsoft Office files, the classification properties (e.g.: Secrecy, Project …) that are tagged on the file in the file server might get a different value assigned (the default column value) when stored on the SharePoint document library

Script command line syntax

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>]

·         file: path to the file to upload (required)

Example: -file C:\Projects\Apollo\test.docx

·         url: URL to the SharePoint site (required)

Example: -url ”http://contoso

·         libPath: relative path to the document library within the site (required)

Example: -path ”Project Apollo”

·         name: name of the target file (optional)

If not specified, it defaults to the source file name as specified by the “file” parameter

Example: -name new.docx

·         sourceAction: indicates how to handle the source file after a successful upload (optional)

o   keep: leave the file in place (default)

o   delete: delete the file

o   url: replace the file with a shortcut to the uploaded document’s URL

Example: -sourceAction keep

·         targetAction: specifies how to handle existing destination documents (optional)

o   overwrite: replace (default)

o   skip: leave existing version and continue

o   fail: return error

Example: -targetAction skip

·         propertyAction: specifies whether to transfer the FCI properties during upload (optional)

o   copy: transfer properties (default)

o   ignore: do not transfer properties, let SharePoint choose defaults

Example: -propertyAction copy

·         user: user name to use for authentication (optional)

The parameter is ignored if “password” is not specified.

·         password: password to use for authentication (optional)

The parameter is ignored if “user” is not specified.

Example: -user contoso\johndoe -password up@load

 

Option 2 – Upload a file to SharePoint using the Official File Web Service that is coupled with a content organizer –e.g. Records 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>

·         file: path to the file to upload (required)

Example: -file C:\Projects\Apollo\test.docx

·         url: URL to the SharePoint site (required)

Example: -url ”http://contoso

·         name: name of the target file (optional)

If not specified, it defaults to the source file name as specified by the “file” parameter

Example: -name new.docx

·         contentType: name of the content type to use for the document (optional)

If not specified, defaults to “Document”

Example: -contentType “Contract”

·         sourceAction: indicates how to handle the source file after a successful upload (optional)

o   keep: leave the file in place (default)

o   delete: delete the file

o   url: replace the file with a shortcut to the uploaded document’s URL

Example: -sourceAction keep

·         propertyAction: specifies whether to transfer the FCI properties during upload (optional)

o   copy: transfer properties (default)

o   ignore: do not transfer properties, let SharePoint choose defaults

Example: -propertyAction copy

·         user: user name to use for authentication (optional)

The parameter is ignored if “password” is not specified.

·         password: password to use for authentication (optional)

The parameter is ignored if “user” is not specified.

Example: -user contoso\johndoe -password up@load

·         additionalProperties: list of extra properties to use for the document (optional)

This parameter must be the last one specified and 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 parameter value.

Example: -additionalProperties PII Boolean True BusinessImpact Choice High

Property Type Mapping

The table below shows how the script maps from FCI property types to SharePoint property types. This mapping should work in most of the cases, but administrators may want to change it in the script if needed, according to the actual types of the SharePoint properties in use.

FSRM Property Type

SharePoint Column Type

SharePoint Type Name

Ordered List

Choice ( choice with drop down )

Choice

Multiple Choice List

MultiChoice ( choice with check box)

MultiChoice

String

Single line of text

Text

Multi String

Multiple lines of text

Note

Integer

Number

Number

Boolean

Boolean

Boolean

Date-time

Date-Time

DateTime

 

#This script is provided "AS IS" with no warranties, and confers no rights.  
 
[CmdletBinding(SupportsShouldProcess=$false)]
 
param(
    [parameter(Mandatory=$true, ParameterSetName="RecordsCenter")]
    [switch] $useOfficialFileWebService,
    
    [parameter(Mandatory=$true)]
    [string] $file,
 
    [parameter(Mandatory=$true)]
    [string] $url,
 
    [parameter(Mandatory=$true, ParameterSetName="Library")]
    [string] $libPath,
 
    [string] $name,
    
    [parameter(ParameterSetName="RecordsCenter")]
    [string] $contentType = "Document",
 
    [ValidateSet("keep", "delete", "url")]
    [string] $sourceAction = "keep",
 
    [parameter(ParameterSetName="Library")]
    [ValidateSet("overwrite", "skip", "fail")]
    [string] $targetAction = "overwrite",
 
    [ValidateSet("copy", "ignore")]
    [string] $propertyAction = "copy",
    
    [string] $user,
    [string] $password,
    
    [parameter(ParameterSetName="RecordsCenter")]
    [switch] $additionalProperties
    )
    
DynamicParam
{
    if($PSCmdlet.ParameterSetName -ieq "RecordsCenter" -and $additionalProperties)
    {
        $paramName = "extraProps"
        
        $attributes = New-Object -TypeName Management.Automation.ParameterAttribute
        $attributes.ValueFromRemainingArguments = $true
        
        $attributeCollection = New-Object -TypeName Collections.ObjectModel.Collection``1[System.Attribute]
        $attributeCollection.Add($attributes)
        
        $param = New-Object -TypeName Management.Automation.RuntimeDefinedParameter -ArgumentList ($paramName, [String[]], $attributeCollection)
 
        $params = New-Object -TypeName Management.Automation.RuntimeDefinedParameterDictionary
        $params.Add($paramName, $param)
        
        $params
    }
}
    
Process
{
 
Set-StrictMode -Version latest
 
 
function GetUrlSuffix
{
    ".uploaded.url"
}
 
function IsUploadedFile
{
    param(
        [string] $name
        )
        
    $suffix = GetUrlSuffix
    
    $name.Length -ge $suffix.Length -and 
    [String]::Compare($name, $name.Length - $suffix.Length, $suffix, 0, $suffix.Length, $true) -eq 0
}
 
function CombineUrls
{
    param(
        [string] $a, 
        [string] $b
        )
    
    if($a.length -eq 0)
    {
        return $b
    }
    
    if($b.length -eq 0)
    {
        return $a
    }
    
    $count = 0
    
    if($a[$a.length - 1] -eq "/")
    {
        ++$count
    }
    
    if($b[0] -eq "/")
    {
        ++$count
    }
    
    switch($count)
    {
        0
        {
            return $a + "/" + $b
        }
 
        1
        {
            return $a + $b
        }
 
        2
        {
            return $a + $b.substring(1)
        }
    }
}
 
function GetUserNameAndDomain
{
    param(
        [string] $user
        )
        
    $arr = $user.Split("\")
    
    if($arr.Length -eq 2)
    {
        $arr[1], $arr[0]
    }
    else
    {
        $arr = $user.Split("@")
 
        if($arr.Length -eq 2)
        {
            $arr[0], $arr[1]
        }
        else
        {
            $user, ""
        }
    }
}
 
function GetNetCredentials
{
    param(
        [string] $user,
        [string] $password
        )
 
    $cred = New-Object -TypeName Net.NetworkCredential
    $cred.UserName, $cred.Domain = GetUserNameAndDomain $user
    $cred.Password = $password
    
    $cred
}
 
function GetPsCredentials
{
    param(
        [string] $user,
        [string] $password
        )
 
    $userName, $domain = GetUserNameAndDomain $user
    $securePassword = ConvertTo-SecureString -AsPlainText -Force -String $password
    
    New-Object -TypeName Management.Automation.PSCredential -ArgumentList ("$domain\$userName", $securePassword)
}
    
function GetWebService
{
    param(
        [string] $namespace,
        [string] $type,
        [string] $url,
        [string] $user,
        [string] $password
        )
 
    #
    # Try to create the object first as the namespace may be there already
    #
    
    try
    {
        $obj = New-Object -TypeName "$namespace.$type"
    }
    catch
    {
        #
        # Create the proxy and try again.
        # This should not require special permissions
        #
        
        if($user.length -ne 0 -and $password.length -ne 0)
        {
            $cred = GetPsCredentials $user $password
            $obj = New-WebServiceProxy -Uri $url -Namespace $namespace -Credential $cred
        }
        else
        {
            $obj = New-WebServiceProxy -Uri $url -Namespace $namespace -UseDefaultCredential
        }
        
        if($obj -eq $null)
        {
            throw "Cannot create Web Proxy from ""$url"""
        }
    }
    
    $obj.Url = $url
 
    if($user.length -ne 0 -and $password.length -ne 0)
    {
        $obj.UseDefaultCredentials = $false
        $obj.Credentials = GetNetCredentials $user $password
    }
    else
    {
        $obj.UseDefaultCredentials = $true
    }
        
    $obj
}
 
function TranslateProperty
{
    param(
        $prop,
        $propDef,
        [bool] $useOfficialFileWebService
        )
 
    if($useOfficialFileWebService)
    {
        $field = New-Object -TypeName WssUpload.RecordsRepositoryProperty
        $field.Name = $prop.Name
        $field.Value = $prop.Value
 
        switch($propDef.Type)
        {
            #
            # FsrmPropertyDefinitionType_OrderedList
            #
            1
            {
                $field.Type = "Choice"
            }
            
            #
            # FsrmPropertyDefinitionType_MultiChoiceList
            #
            2
            {
                $field.Type = "MultiChoice"
 
                $field.Value = $prop.Value.Replace("|", ";#")
            }
            
            #
            # FsrmPropertyDefinitionType_String
            #
            4
            {
                $field.Type = "Text"
            }
            
            #
            # FsrmPropertyDefinitionType_MultiString
            #
            5
            {
                $field.Type = "Note"
            }
            
            #
            # FsrmPropertyDefinitionType_Int
            #
            6
            {
                $field.Type = "Number"
            }
            
            #
            # FsrmPropertyDefinitionType_Bool
            #
            7
            {
                $field.Type = "Boolean"
                
                switch($prop.Value)
                {
                    "0"
                    {
                        $field.Value = "False"
                    }
 
                    "1"
                    {
                        $field.Value = "True"
                    }
                }
            }
            
            #
            # FsrmPropertyDefinitionType_Date
            #
            8
            {
                $field.Type = "DateTime"
                
                #
                # Convert to ISO8601
                #
                
                $dateTime = [DateTime]::FromFileTimeUtc([Int64] $prop.Value)
                $field.Value = $dateTime.ToString("o")
            }
        }
    }
    else
    {
        $field = New-Object -TypeName WssUpload.FieldInformation
        $field.DisplayName = $prop.Name
        $field.Value = $prop.Value
 
        switch($propDef.Type)
        {
            #
            # FsrmPropertyDefinitionType_OrderedList
            #
            1
            {
                $field.Type = [WssUpload.FieldType]::Choice
            }
            
            #
            # FsrmPropertyDefinitionType_MultiChoiceList
            #
            2
            {
                $field.Type = [WssUpload.FieldType]::MultiChoice
 
                $field.Value = $prop.Value.Replace("|", ";#")
            }
            
            #
            # FsrmPropertyDefinitionType_String
            #
            4
            {
                $field.Type = [WssUpload.FieldType]::Text
            }
            
            #
            # FsrmPropertyDefinitionType_MultiString
            #
            5
            {
                $field.Type = [WssUpload.FieldType]::Note
            }
            
            #
            # FsrmPropertyDefinitionType_Int
            #
            6
            {
                $field.Type = [WssUpload.FieldType]::Number
            }
            
            #
            # FsrmPropertyDefinitionType_Bool
            #
            7
            {
                $field.Type = [WssUpload.FieldType]::Boolean
                
                switch($prop.Value)
                {
                    "0"
                    {
                        $field.Value = "False"
                    }
 
                    "1"
                    {
                        $field.Value = "True"
                    }
                }
            }
            
            #
            # FsrmPropertyDefinitionType_Date
            #
            8
            {
                $field.Type = [WssUpload.FieldType]::DateTime
                
                #
                # Convert to ISO8601
                #
                
                $dateTime = [DateTime]::FromFileTimeUtc([Int64] $prop.Value)
                $field.Value = $dateTime.ToString("o")
            }
        }
    }    
    
    $field
}
 
function ReadProperties
{
    param(
        [string] $fileName,
        [bool] $useOfficialFileWebService
        )
        
    $fields = @()
 
    $fsrmMgr = New-Object -ComObject "Fsrm.FsrmClassificationManager"
    $props = $fsrmMgr.EnumFileProperties($filename)
    
    foreach($prop in $props)
    {
        try
        {
            $propDef = $fsrmMgr.GetPropertyDefinition($prop.Name)
        }
        catch
        {
            #
            # Most probably not an FSRM property; just skip
            #
            continue
        }
        
 
        $fields += TranslateProperty $prop $propDef $useOfficialFileWebService
    }    
    
    $fields
}
 
function CreatePropertiesFromArray
{
    param(
        [string[]] $props
        )
    
    $fields = @()
    
    for($i = 0; $i + 2 -lt $props.Length; $i += 3)
    {
        $field = New-Object -TypeName WssUpload.RecordsRepositoryProperty
        
        $field.Name = $props[$i]
        $field.Type = $props[$i + 1]
        $field.Value = $props[$i + 2]
        
        $fields += $field
    }
    
    $fields
}
 
function CreateUrl
{
    param(
        [string] $src,
        [string] $dest
        )
 
    $src += GetUrlSuffix
    
    try
    {
        $writer = New-Object -TypeName IO.StreamWriter -ArgumentList $src
        $writer.WriteLine("[InternetShortcut]")
        $writer.WriteLine("URL=$dest")
    }
    finally
    {
        $writer.Dispose()
    }
}
 
function UploadToLibrary
{
    param(
        [string] $file,
        [string] $url,
        [string] $libPath,
        [string] $name,
        [string] $sourceAction,
        [string] $targetAction,
        [string] $propertyAction,
        [string] $user,
        [string] $password
        )
    
    #
    # Skip previously uploaded files
    #
    if(IsUploadedFile $file)
    {
        return
    }
    
    if($name.Length -eq 0)
    {
        #
        # No rename
        #
        $name = [IO.Path]::GetFileName($file)
    }
    
    $relPath = CombineUrls $libPath $name
 
    if($targetAction -ine "overwrite")
    {
        #
        # See if the target exists
        #
        
        $urlVer = CombineUrls $url "_vti_bin/versions.asmx"
        $wsVersion = GetWebService "WssUpload" "Versions" $urlVer $user $password
        $targetPresent = $true
        
        try
        {
            $dummy = $wsVersion.Getversions($relPath)
        }
        catch
        {
            $targetPresent = $false
        }
        
        if($targetPresent)
        {
            if($targetAction -ieq "skip")
            {
                return
            }
            
            throw "Target file """ + $relPath + """ already exists"
        }
    }
    
    $urlCopy = CombineUrls $url "_vti_bin/copy.asmx"
    $wsCopy = GetWebService "WssUpload" "Copy" $urlCopy $user $password
    
    $data = [IO.File]::ReadAllBytes($file)
    $dest = @(CombineUrls $url $relPath)
    $fields = @()
    
    if($propertyAction -ieq "copy")
    {
        $fields = @(ReadProperties $file $false)
    }
    
    $results = $null
    $ret = $wsCopy.CopyIntoItems(" ", $dest, $fields, $data, [ref] $results)
    
    if($ret -ne 0)
    {
        throw "Copy request did not complete"
    }
    
    if($results[0].ErrorCode -ne 0)
    {
        throw $results[0].ErrorMessage
    }
    
    switch($sourceAction)
    {
        "delete"
        {
            [IO.File]::Delete($file)
        }
        
        "url"
        {
            [IO.File]::Delete($file)
            CreateUrl $file $dest[0]
        }
    }
}
 
function UploadToRecordsCenter
{
    param(
        [string] $file,
        [string] $url,
        [string] $name,
        [string] $recordRouting,
        [string] $contentType,
        [string[]] $extraProps,
        [string] $sourceAction,
        [string] $propertyAction,
        [string] $user,
        [string] $password
        )
        
    #
    # We need groups of three strings for additional properties: name, type, value
    #
    if($extraProps.Length % 3 -ne 0)
    {
        throw "Invalid number of additional property items"
    }
    
    #
    # Skip previously uploaded files
    #
    if(IsUploadedFile $file)
    {
        return
    }
    
    if($name.Length -eq 0)
    {
        #
        # No rename
        #
        $name = [IO.Path]::GetFileName($file)
    }
    
    $urlOfficialFile = CombineUrls $url "_vti_bin/officialfile.asmx"
    $wsRepository = GetWebService "WssUpload" "RecordsRepository" $urlOfficialFile $user $password
    
    $data = [IO.File]::ReadAllBytes($file)
    
    #
    # Prepare the properties array. Start with the required properties...
    #
    $fields = @(CreatePropertiesFromArray @(
        "FileLeafRef", "Text", $name,
        "ContentType", "Text", $contentType
        ))
    
    #
    # ... then add FSRM properties if needed
    #
    if($propertyAction -ieq "copy")
    {
        $fields += @(ReadProperties $file $true)
    }
 
    #
    # ... and finally add any extra properties passed in
    #    
    $fields += @(CreatePropertiesFromArray $extraProps)
 
    $userName, $domain = GetUserNameAndDomain $user
    
    if($domain.length -ne 0)
    {
        $domain += "\"
    }
    
    $userName = "$domain$userName"
    
    if($userName.Length -eq 0)
    {
        #
        # We need to pass something here
        #
        $userName = " "
    }
    
    $res = $wsRepository.SubmitFile($data, $fields, $recordRouting, $name, $userName)
    
    #
    # Parse the result
    #
    
    $xmlDoc = New-Object -TypeName Xml.XmlDocument
    
    #
    # We need to wrap the XML result with a document element
    #
    
    $xmlDoc.LoadXml("<x>$res</x>")
    $resultCode = "invalid response format"
    $targetUrl = ""
    $xmlNode = $xmlDoc.DocumentElement.SelectSingleNode("ResultCode")
    
    if($xmlNode -ne $null)
    {
        if($xmlNode.InnerText -eq "Success")
        {
            $xmlNode = $xmlDoc.DocumentElement.SelectSingleNode("ResultUrl")
            
            if($xmlNode -ne $null)
            {
                $targetUrl = $xmlNode.InnerText
            }
        }
        else
        {
            $resultCode = $xmlNode.InnerText
        }
    }
    
    if($targetUrl.Length -eq 0)
    {
        throw "Error submitting file: $resultCode"
    }
    
    switch($sourceAction)
    {
        "delete"
        {
            [IO.File]::Delete($file)
        }
        
        "url"
        {
            [IO.File]::Delete($file)
            CreateUrl $file $targetUrl
        }
    }
}
 
try
{
    if($PSCmdlet.ParameterSetName -ieq "Library")
    {
        UploadToLibrary $file $url $libPath $name $sourceAction $targetAction $propertyAction $user $password
    }
    else
    {
        $extraProps = $null
        
        if(-not $PSCmdlet.MyInvocation.BoundParameters.TryGetValue("extraProps", [ref] $extraProps))
        {
            $extraProps = @()
        }
        
        UploadToRecordsCenter $file $url $name $null $contentType $extraProps $sourceAction $propertyAction $user $password
    }
}
catch
{
    #
    # TODO: Add logging
    #
 
    throw
}
 
}
<#
    .SYNOPSIS
    Upload a file to a SharePoint library or content organizer.
    
    .DESCRIPTION
    The script uploads a file to a SharePoint document library or content organizer. Optionally, it also deletes the source file or replaces it with a shortcut to the uploaded item. 
    The source file is identified by its file system path. The SharePoint library is identified by the site URL and the relative path to the document library. The content organizer is only idendified by the site URL.
    The uploaded document can have the same name as the source file or be given a different name.
    Classification properties can either be propagated to the target or ignored. The target library should have a content type consistent with the classification properties.
    
    .NOTES
    
    Classification types are mapped to SharePoint content types as follows:
    
        FsrmPropertyDefinitionType_OrderedList -> Choice
        FsrmPropertyDefinitionType_MultiChoiceList -> MultiChoice
        FsrmPropertyDefinitionType_String -> Single line of text
        FsrmPropertyDefinitionType_MultiString -> Multiple lines of text
        FsrmPropertyDefinitionType_Int -> Number
        FsrmPropertyDefinitionType_Bool -> Boolean
        FsrmPropertyDefinitionType_Date -> DateTime
 
    This mapping may need changing according to how the target SharePoint content type is actually defined.
    
    .PARAMETER useOfficialFileWebService
    If specified, the file is uploaded to a content organizer by using the Official File Web service
    
    .PARAMETER file
    File system path to the file to be uploaded
    
    .PARAMETER url
    URL to the target SharePoint site
    
    .PARAMETER libPath
    Relative path to the target document library
    
    .PARAMETER name
    Target document name. If not specified, it defaults to the source file name.
    
    .PARAMETER sourceAction
    Specifies what to do with the source file after it is successfully uploaded. Can be one of:
    
        keep    -leave the source file in place (default)
        delete  -delete the source file
        url     -create an Internet shortcut to the target document
        
    .PARAMETER targetAction
    Specifies how to handle existing target documents. Can be one of:
    
        overwrite -overwrite any existing target with the source file (default)
        skip      -do not upload the file and return success
        fail      -do not upload the file and return error
        
    .PARAMETER propertyAction
    Specifies how to propagate classification properties from source to target. Can be one of:
    
        copy   -copy classification properties of the source to the target (default)
        ignore -do not copy classification properties, let target get default property values
        
    .PARAMETER user
        Specifies, togethter with "-password" parameter, the credentials to use for the operation. Can be in the form of "domain\user" or "user@domain". Ignored if "-password" is not specified.
        
    .PARAMETER password
        Specifies, togethter with "-user" parameter, the credentials to use for the operation. Ignored if "-user" is not specified.
        
    .EXAMPLE
    
    FciSharePointUpload.ps1 -file c:\docs\foo.docx -url http://sharepoint/sites/foo -libPath "Shared Documents"
 
    Uploads a file with no rename using default credentials.
        
    .EXAMPLE
    
    FciSharePointUpload.ps1 -file c:\docs\foo.docx -url http://sharepoint/sites/foo -libPath "Shared Documents" -name bar.docx -user "mydomain\myuser" -password "mypassword"
        
    Uploads a file with a different name using explicit credentials.
 
    .EXAMPLE
    
    FciSharePointUpload.ps1 -file c:\docs\foo.docx -url http://sharepoint/sites/foo -libPath "Shared Documents" -sourceAction url -targetAction skip -propertyAction ignore
 
    Uploads a file if not already present with default properties and replaces the source with an Internet shortcut.
    
    .EXAMPLE
    
    FciSharePointUpload.ps1 -useOfficialFileWebService -file c:\docs\foo.docx -url http://sharepoint/sites/foo
    
    Uploads a file to a content organizer site.
#>


Permalink | Comments (0) | Post RSSRSS comment feed