SkyDrive Pro | PowerShell Script checks and moves folders and files
SkyDrive Pro and PowerShell?
Yes, no discrepancy. I used PowerShell because the script should be customizable. But in turn. Again and again, users have problems with files that do not synchronize with SharePoint (online) or SharePoint on premise. And the users do not know, how they should solve the problem. sometimes users want to move complex folder structures into a SharePoint library(see remarks on the end of this blog post). And Andre Kieft, Microsoft partner technical consultant from the Netherlands has brought me with his little script on the right track.
If you are looking for a german description, here it is
Appended [09.09.13] Andre Kieft wrote an excellent Blog post on technet
Appended [03.10.13] Due to changes from Microsoft on SharePoint Online, it is now allowed, to sync Files with the extension *.exe und *.dll. I have made these changes also on the Powershell-Script.
Most problems with folders and files that are added in the SkyDrive Pro folder and then cause a synchronization error, are the restrictions on the SharePoint Server 2013:
However, we must distinguish
|SharePoint Online (Office 365)||blocked file extensions (19)
f.e: .ashx, .asmx… .xamlx
|SharePoint Server 2013 and SharePoint Foundation||blocked file extensions (104)
f.e.. .bas, .bat,… .wsh
|File- und Folder restrictions||not allowed characters and extensions (9+20)
f.e.: “&”,”%”, or “#”, …
|length of folder or filename||folder< 256 , file < 128|
Depending of the SharePoint Server a user must look between 48 and 133 restrictions on each folder and filename.
- Simple copying a file into the SkyDrive Pro folder
- Or copy entire folder with subfolders and files contained therein.
SkyDrive Pro synchronizes only. But the user see sync errors. Microsoft is working on this problem on SharePoint (online), may be you will see in the near future , that it will be allowed to use the “&” character in a filename. But not right now
The PowerShell Script SDPMove.ps1
|OutPutPath||the destination folder
f.e: “C:\Users\hb\SkyDrive @ myCompany”
if it is not specified the script will check against SharePoint Server on premise.
if specified, the script will check against SharePoint Online
if not specified, the script will only check and make no change
(but you may see some errors)
if specified, the script will check, change and
a) folders will be copied to the destination folder
if not specified, the script will give you minimal messages in the PowerShell console.
if specified, the script will give you all messages
if not specified, the script will give messages in german language.
This time 2 languages implemented: German and English
Parameter: German, English
When it is called, the source directory is processed hierarchically. Here the flow chart
Invalid characters are replaced.
Invalid characters are replaced.
|folder and files||Is determined by a change, that a folder or file with the same name exits, the script add –HBx to the folder or filename. The x stands for a numerical value.
the script cuts too long folder and filenames.
You may notice and the Script name SDPMove says: the files will be moved to the destination directory. You may do a copy of the source directory in advance.
Here a small selection, which changes SDPMove does:
|Test.dll.txt||no change, remains left|
|try.asmx||no change, remains left|
Here you can download the zip file with the script
Unpack you the zip file and place SDPMove. ps1 for example in the folder C:\PowershellScripts
Start PowerShell and navigate to the path C:\PowershellScripts
We assume you have a folder containing a complex structure with additional folders and files: "C:\Test"
You want to bring the "C:\Test" folder and all subfolders contained in it and all files on SkyDrive Pro: "C:\Users\Benutzer\SkyDrive @ myCompany"
Then the command is:
.\SDPMove.ps1 C:\Test “C:\Users\Benutzer\SkyDrive @ myCompany” –SPOnline –Fix –Show –Language English
Problems when you run? (Execution policy)
look here and run Set-ExecutionPolicy RemoteSigned (as adnministrator)
You may do script changes. If you run it against a Sharepoint Server On Premise you have to it. Check the file-extensions with you SharePoint administrator. If he has some more blocked file-extensions, than you have to adjust Init_SPOnPremiseIllegal. The same procedure, if he has allowed some file extensions.
SDPMove is suitable also for moving complex folder structures. Whether it makes sense to bring a previously existing file folder structure 1:1 for SharePoint, this is question, SharePoint consultants should get here first of all their consulting skills in the game
Feedback and comments welcome