Introduction
SQList can export SharePoint document libraries to SQL Server, including document contents stored as binary data. If you also need those documents as files on a file system, the accompanying PowerShell script provides a simple way to write the exported contents to disk.
How the script works
The script reads the rows for one document library from SQL Server and writes each document beneath a configured output folder. By default, it uses the SharePoint FileRef value to recreate the folder path and filename. You can adapt the path pattern to use other columns or arrange the output differently.
When a file already exists, the script compares its last modified timestamp with the timestamp stored in SQL Server. If the timestamps match, it skips writing the file, so unchanged documents are not rewritten on subsequent runs.
Scope and limitations
- The script processes one document library at a time.
- It exports documents from the SQL Server data to a file system.
- It does not delete local files when documents are deleted from SharePoint or removed from the SQL export.
This is a file export, not a synchronisation process that mirrors deletions. We provide the script as-is, without warranty of any kind. AxioWorks accepts no responsibility or liability for loss or damage arising from its use. Review and test it in a non-production environment, and verify your backups and output before running it against production data. The script is a practical example for customers who need files on disk and can be modified to suit other requirements. Review its configuration, SQL connection details, table and column names, and output location before running it.
Download the script
Download Export-SharePointDocuments.zip
Conclusion
Once SQList has exported a document library to SQL Server, this script can provide a straightforward starting point for writing its documents to a file system. It skips files that have not changed, processes one library at a time, and leaves local files in place when source documents are deleted.
For further information or technical support, please contact the AxioWorks Support Team at support@axioworks.com.