NOTE: this does not migrate security
NOTE: does not check for invalid charcters
NOTE: must be run on a sharepoint server joined to the farm
function ProcessDirectory($directory, $spfolder){
$directory.GetDirectories() foreach{
#create direcotry
write-host "creating directory" $_.Name
$newfolder = $spfolder.SubFolders.Add($_.Name)
#recurse directory
ProcessDirectory $_ $newfolder
}
$directory.GetFiles() foreach{
#uploadfile
write-host "uploading file" $_.Name
$newfile = $spfolder.Files.Add($_.Name,$_.OpenRead(),$true)
}
}
#you could use a local drive. If migrating from a remote server mount the share
#net use X: \\fileshare\sharename
#change current directory
x:
#get web
$web = get-spweb "http://companyweb"
#get the document library
$list = $web.Lists["TestMigration"]
$rootfolder = $list.RootFolder
#get DirectoryInfo object
$currentfolder = get-item .
#start process
ProcessDirectory $currentfolder $rootfolder