powershell sharepoint copy file to other site collection
Shell
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
Also in Shell:
- Title
- unable to resolve module safe area context from index.tsx
- Category
- Shell
- Title
- sh declare variable
- Category
- Shell
- Title
- ubuntu camera not longer found
- Category
- Shell
- Title
- npm list global packages
- Category
- Shell
- Title
- linux zip a directory
- Category
- Shell
- Title
- install pip ubuntu
- Category
- Shell
- Title
- npm install --global vue-cli
- Category
- Shell
- Title
- checking for existing ssh keys
- Category
- Shell
- Title
- docker run command on container
- Category
- Shell
- Title
- force git to use ssh
- Category
- Shell
- Title
- ubuntu find file with text
- Category
- Shell
- Title
- randomly choose n rows from a file linux
- Category
- Shell
- Title
- linux screen brightness command line
- Category
- Shell
- Title
- install ruby mac
- Category
- Shell
- Title
- angular add service worker
- Category
- Shell
- Title
- ubuntu sites-available location
- Category
- Shell
- Title
- shell hide tab
- Category
- Shell
- Title
- how to import microsoft.online sharepoint powershell
- Category
- Shell
- Title
- git remove remote
- Category
- Shell
- Title
- "at" ubuntu script dschedule
- Category
- Shell
- Title
- babel source maps
- Category
- Shell
- Title
- split large file into smaller files
- Category
- Shell
- Title
- git flow init
- Category
- Shell
- Title
- download images from url terminal
- Category
- Shell
- Title
- bash append file
- Category
- Shell
- Title
- wheres i3 config file
- Category
- Shell
- Title
- linux generate file
- Category
- Shell
- Title
- github undo last pushed commit
- Category
- Shell
- Title
- git fklow init
- Category
- Shell
- Title
- installing helm and tiller on minikube
- Category
- Shell
- Title
- git grep across all branches
- Category
- Shell
- Title
- ubuntu list running applications
- Category
- Shell
- Title
- git reset
- Category
- Shell
- Title
- cosmicjs
- Category
- Shell
- Title
- how to save environment variables ubuntu
- Category
- Shell
- Title
- adding jars to classpath in linux
- Category
- Shell
- Title
- linux grep
- Category
- Shell
- Title
- command line how to find all files that have a string
- Category
- Shell
- Title
- how to delete a non empty directory in linux
- Category
- Shell
- Title
- delete github repository curl
- Category
- Shell
- Title
- powershell map array
- Category
- Shell
- Title
- how to unstage changes in git
- Category
- Shell
- Title
- linux command to list directory size
- Category
- Shell
- Title
- mac cleanup github
- Category
- Shell
- Title
- installing caddy server in ubuntu 18
- Category
- Shell
- Title
- usr/bin/env: ‘node’: No such file or directory
- Category
- Shell
- Title
- how to perform mathematical operations in shell script
- Category
- Shell
- Title
- conda install mmcv
- Category
- Shell
- Title
- remove submodule git
- Category
- Shell
- Title
- install chromedriver linux command line
- Category
- Shell
- Title
- git config core.autocrlf true
- Category
- Shell
- Title
- greater than certain value from pipe shell
- Category
- Shell
- Title
- check disk space linux
- Category
- Shell
- Title
- ping a port linux
- Category
- Shell
- Title
- simple nodejs dockerfile
- Category
- Shell
- Title
- uid : unable to do port forwarding: socat not found
- Category
- Shell
- Title
- delete a github repository using bash
- Category
- Shell
- Title
- how to get stashed on git
- Category
- Shell
- Title
- grep for all .py files containing a word
- Category
- Shell
- Title
- git push all branches
- Category
- Shell
- Title
- linux restrict process network access
- Category
- Shell
- Title
- append a string in all files name linux
- Category
- Shell
- Title
- npm install express-handlebars
- Category
- Shell
- Title
- powershell script enable tls 1.2
- Category
- Shell
- Title
- Error: Node Sass does not yet support your current environment
- Category
- Shell
- Title
- how to create a branch in git
- Category
- Shell
- Title
- linux replace string in all files
- Category
- Shell
- Title
- where is path on klai linux
- Category
- Shell
- Title
- install node in nvm
- Category
- Shell
- Title
- how to change dotnet version
- Category
- Shell
- Title
- remotelog muirey03 github
- Category
- Shell
- Title
- how to update pip in linux
- Category
- Shell
- Title
- how to revert commit in git
- Category
- Shell
- Title
- check running process in linux
- Category
- Shell
- Title
- ansible-galaxy install to specific directory
- Category
- Shell
- Title
- how to make a tarball in linux
- Category
- Shell
- Title
- how to find the path of a command in linux
- Category
- Shell
- Title
- get local node version
- Category
- Shell
- Title
- date command in linux
- Category
- Shell
- Title
- undo git add
- Category
- Shell
- Title
- ubuntu unzip zip
- Category
- Shell
- Title
- react navigation install
- Category
- Shell
- Title
- scheduler ubuntu cmd
- Category
- Shell
- Title
- delete github repository git bash
- Category
- Shell
- Title
- scp download file
- Category
- Shell
- Title
- resart network
- Category
- Shell
- Title
- extract tar.gz ubuntu terminal
- Category
- Shell
- Title
- find npm version
- Category
- Shell
- Title
- Got permission denied while trying to connect to the Docker daemon socket
- Category
- Shell
- Title
- bash get first argument
- Category
- Shell
- Title
- docker remove image
- Category
- Shell
- Title
- unzip gz file linux
- Category
- Shell
- Title
- how to check in which brach we are in git
- Category
- Shell
- Title
- remove git credentials terminal
- Category
- Shell
- Title
- command not found: nvm
- Category
- Shell
- Title
- Shell query displays all citizens with an age greater than or equal to 21
- Category
- Shell
- Title
- close chrome tab from command line ubuntu
- Category
- Shell
- Title
- git commit
- Category
- Shell
- Title
- hasura squashmigrations
- Category
- Shell
- Title
- how to install yum uitls
- Category
- Shell