Horje
powershell sharepoint copy file to other site collection Code Example
powershell sharepoint copy file to other site collection
Add-PSSnapIn "Microsoft.SharePoint.PowerShell"

## 
#Set Static Variables 
## 

$SourceWebURL = "http://WebAppURL/sites/Area/Master" 
$SourceLibraryTitle = "Web" 
$DestinationWebURL = "http://WebAppURL/sites/OtherSiteName" 
$DestinationLibraryTitle = "Web"
$FileName = "Resources.aspx"

## 
#Begin Script 
## 

$sWeb = Get-SPWeb $SourceWebURL 
#$sList = $sWeb.Lists | ? {$_.Title -eq $SourceLibraryTitle} 
$dWeb = Get-SPWeb $DestinationWebURL 
#$dList = $dWeb.Lists | ? {$_.title -like $DestinationLibraryTitle} 

$SourceFile=$sWeb.GetFile($SourceWebURL+"/"+$SourceLibraryTitle+"/"+$FileName)
$TargetFolder = $dWeb.GetFolder($DestinationLibraryTitle)
#Copy File from the Source
$NewFile = $TargetFolder.Files.Add($SourceFile.Name, $SourceFile.OpenBinary(),$True)

#Copy Meta-Data from Source
Foreach($Field in $SourceFile.Item.Fields)
{
    If(!$Field.ReadOnlyField)
    {
        if($NewFile.Item.Fields.ContainsField($Field.InternalName))
        {
            $NewFile.Item[$Field.InternalName] = $SourceFile.Item[$Field.InternalName]
        }
    }
}
#Update
$NewFile.Item.UpdateOverwriteVersion()

Write-host "Copied File:"$SourceFile.Name




Shell

Related
depmod: not found Code Example depmod: not found Code Example
The following packages have unmet dependencies: nginx : Depends: libssl1.0.0 (>= 1.0.2~beta3) Code Example The following packages have unmet dependencies: nginx : Depends: libssl1.0.0 (>= 1.0.2~beta3) Code Example
gitignore for eclipse Code Example gitignore for eclipse Code Example
install flask dockerfile freeze Code Example install flask dockerfile freeze Code Example
pod install not working bad interpreter: No such file or directory Code Example pod install not working bad interpreter: No such file or directory Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10