OneDrive for Business blocks file and folder names that contain specific characters. When you try to sync a file with an unsupported character, OneDrive shows a red X and the file stays in a pending state. This happens because Windows allows these characters in local file names, but OneDrive’s cloud storage engine does not support them. This article explains which characters are blocked, how to find them in your files before uploading, and how to rename files to avoid sync failures.
Key Takeaways: Find and Remove Unsupported Characters Before OneDrive Sync
- File Explorer search with
~"andname:operators: Use wildcard searches to locate files containing~"andname:operators to find files containing tilde, quotation marks, and other blocked characters. - PowerShell script for bulk detection: Run a simple command to list all files with unsupported characters in a folder and export the results to a text file.
- OneDrive sync status icons in File Explorer: Check for the red X icon before uploading to confirm which files OneDrive will reject.
Why OneDrive Blocks Certain Characters in File and Folder Names
OneDrive for Business uses the SharePoint Online storage backend. SharePoint Online follows a stricter naming convention than Windows NTFS. The characters that are allowed in Windows file names are not all permitted in SharePoint. When you attempt to sync a file with a blocked character, the OneDrive sync engine cannot create the corresponding cloud item. The file remains in the local OneDrive folder with a red X overlay icon, and the sync status reads “Sync pending” or “Can’t upload.” The blocked characters include the tilde (~), quotation mark ("), number sign (#), percent (%), ampersand (&), asterisk (), colon (:), less than (<), greater than (>), question mark (?), backslash (\), and forward slash (/). Additionally, file names cannot start with a period (.) or contain trailing spaces or trailing periods. The full list is documented in Microsoft’s SharePoint file name restrictions. Understanding this difference between Windows and OneDrive is the first step to avoiding upload errors.
How to Scan Local Files for Unsupported Characters Before Upload
You can detect unsupported characters using three methods: File Explorer search, PowerShell, and a manual review of the OneDrive sync status. Each method works best for different file quantities. Use File Explorer for a quick check on a small folder. Use PowerShell for scanning hundreds or thousands of files in bulk. Use the OneDrive status icons to verify the result after scanning.
Method 1: File Explorer Search with Wildcards
- Open the folder you plan to upload
Navigate to the folder in File Explorer. Do not open the OneDrive folder yet if you want to scan before moving files. - Click the Search box in the upper-right corner
Type~"and press Enter. This search finds files that contain a tilde, which is one of the blocked characters. If no results appear, the folder is clear of tildes. - Search for each blocked character individually
You cannot search for all characters in one query. Repeat the search for",#,%,&,:,<,>,?,\, and/. For the asterisk, use the searchname:but be aware that File Explorer treatsas a wildcard, so this search is not reliable. Use PowerShell for the asterisk instead. - Rename any files found with blocked characters
Right-click the file, select Rename, and replace the blocked character with a hyphen or underscore. For example, changereport#1.docxtoreport-1.docx.
Method 2: PowerShell Script to List All Files with Unsupported Characters
- Open PowerShell as an administrator
Press the Windows key, type PowerShell, right-click Windows PowerShell, and select Run as administrator. - Navigate to the folder you want to scan
Typecd "C:\Path\To\Your\Folder"and press Enter. Replace the path with your actual folder location. - Run the detection script
Copy and paste the following command, then press Enter:Get-ChildItem -Recurse | Where-Object { $_.Name -match '[~"#%&:<>?\\/]' } | Select-Object FullName
This script lists the full path of every file and folder whose name contains any of the blocked characters. The output appears in the PowerShell window. - Export the results to a text file for easier review
Run this command instead to save the list:Get-ChildItem -Recurse | Where-Object { $_.Name -match '[~"#%&:<>?\\/]' } | Select-Object FullName | Out-File -FilePath "C:\Temp\blocked_chars.txt"
Open the text file in Notepad to see all flagged files. Rename each file directly in File Explorer.
Method 3: Check OneDrive Sync Status Before Moving Files
- Copy the files to your OneDrive folder
If you already scanned and renamed files, copy them into the OneDrive folder. Do not move them yet if you want to verify sync status. - Wait for OneDrive to process the files
OneDrive shows a blue circular sync icon for files that are uploading. After a few seconds, check the file icon overlay. - Look for the red X icon
A red X means the file failed to sync. Right-click the file and select View sync issues. The OneDrive activity center shows the exact error message, which often includes "The file name contains invalid characters." - Rename the file directly in the OneDrive folder
Right-click the file, select Rename, remove the blocked character, and press Enter. OneDrive automatically retries the upload.
Common Mistakes When Handling Unsupported Characters
Using the asterisk in File Explorer search
File Explorer treats the asterisk as a wildcard in search queries. Searching for returns all files, not just those containing an asterisk in the name. Use the PowerShell method to detect files with an asterisk in the name.
Trailing spaces and trailing periods
Windows allows file names like notes.txt with a trailing space or notes..txt with a trailing period. OneDrive removes trailing spaces and trailing periods during upload, which can cause a sync conflict if the same file already exists without the trailing characters. To avoid this, rename files to remove trailing spaces and periods before copying them to OneDrive.
Ignoring folder names
OneDrive blocks unsupported characters in folder names as well. If a folder name contains a colon or ampersand, all files inside that folder fail to sync. Run the PowerShell script with the -Recurse flag to catch folder names too.
File Explorer Search vs PowerShell vs OneDrive Status: Which Detection Method to Use
| Item | File Explorer Search | PowerShell Script | OneDrive Sync Status |
|---|---|---|---|
| Best for | Quick check of a single folder with fewer than 50 files | Bulk scan of thousands of files across subfolders | Final verification after files are already in the OneDrive folder |
| Detects all blocked characters | No — asterisk cannot be reliably searched | Yes — all characters in the regex pattern are detected | Yes — but only after upload attempt fails |
| Requires installation | No | No — PowerShell is built into Windows | No |
| Output format | File Explorer results pane | Text file or console list | Red X icon and error message in activity center |
| Time to complete | 30 seconds per character search | 2-5 seconds for 1000 files | 10-30 seconds after file copy |
Use File Explorer search when you have a small number of files and you know which character to look for. Use the PowerShell script when you need a comprehensive scan of a large folder structure. Use the OneDrive sync status only when you have already moved files and need to confirm the result. Combining PowerShell detection with a rename step before moving files will prevent sync errors entirely.