Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We are looking at moving files of about 350gb of files to sharepoint. What would be the ideal tool to use.Will powershell do the job? Thanks in Advance Cheers

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Definitely PowerShell is here to rescue you! Here is the small function which uploads the files from a directory c:\myfolder\ :

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
function UploadAllFiles($WebURL, $DocLibName, $FolderPath)
{

 #Get the Web & Lists to upload the file
 $site = New-Object Microsoft.SharePoint.SPSite($WebURL)
 $web= $site.OpenWeb()


#Get the Target Document Library to upload
$List = $Web.GetFolder($DocLibName)

#Get the Files from Local Folder
$Files = Get-ChildItem $FolderPath #You can filter files by: -filter “*.pdf” 

#upload the files
foreach ($File in $Files)
{
    #Get the Contents of the file to FileStream 
    $stream = (Get-Item $file.FullName).OpenRead()         
    # Set Metadata Hashtable For the file - OPTIONAL
    $Metadata = @{"Country" = "United States"; "Domain" = "Sales"}                
    $uploaded = $List.Files.Add($File.Name, $stream, $Metadata, $TRUE)               
    $stream.Dispose()
}

#Dispose the site object
$site.Dispose()
}

#call the upload function
UploadAllFiles "http://testserver/sites/sales/" "Document Library Name" "c:\myfolder\"

Happy SharePointing! :)

share|improve this answer
    
Cheers taught as much –  naijacoder Dec 4 '12 at 23:59
    
About if i have multiple folders with children.How can i copy that across. Cheers –  naijacoder Dec 5 '12 at 7:47
    
do you mean multiple folders in the source of the destination site? –  Falak Mahmood Dec 5 '12 at 9:22
    
Yes multiple folders as the source and it needs to copy across to the destination as it is? Cheers –  naijacoder Dec 5 '12 at 11:43
    
Any ideas on how to iterate through all the folders and add all child documents? –  naijacoder Dec 6 '12 at 4:54
show 1 more comment

You should use the "-Recurse" option with this line below, then you will get all the child items as well.

Get the Files from Local Folder

$Files = Get-ChildItem $FolderPath #You can filter files by: -filter “*.pdf” -Recurse
share|improve this answer
    
Thanks i would give that a try. –  naijacoder Feb 15 '13 at 6:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.