Solved

File name too long to sync onedrive

Posted on 2014-12-19
29
695 Views
Last Modified: 2015-04-11
I have recently moved all my dropbox files to onedrive in an effort to migrate.  Unfortunately, one drive does not provide an easy way to resolve the file size errors.  You cannot see the file in internet explorer view.  You are not told how many files there are to shorten.  And you must do them one-by-one.  There has to be a better way.

Assistance is greatly appreciated.
0
Comment
Question by:frugalmule
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 17
  • 10
  • 2
29 Comments
 

Accepted Solution

by:
rezsupport earned 84 total points
ID: 40510491
Sure, here is a script that should help automate the process for you. Save it as a ps1.



function Check-IllegalCharacters ($Path, [switch]$Fix, [switch]$Verbose)
{
    Write-Host Checking files in $Path, please wait...
    #Get all files and folders under the path specified
    $items = Get-ChildItem -Path $Path -Recurse
    foreach ($item in $items)
    {
        #Check if the item is a file or a folder
        if ($item.PSIsContainer) { $type = "Folder" }
        else { $type = "File" }
       
        #Report item has been found if verbose mode is selected
        if ($Verbose) { Write-Host Found a $type called $item.FullName }
       
        #Check if item name is 128 characters or more in length
        if ($item.Name.Length -gt 127)
        {
            Write-Host $type $item.Name is 128 characters or over and will need to be truncated -ForegroundColor Red
        }
        else
        {
            #Got this from http://powershell.com/cs/blogs/tips/archive/2011/05/20/finding-multiple-regex-matches.aspx
            $illegalChars = '[&{}~#%]'
            filter Matches($illegalChars)
            {
                $item.Name | Select-String -AllMatches $illegalChars |
                Select-Object -ExpandProperty Matches
                Select-Object -ExpandProperty Values
            }
           
            #Replace illegal characters with legal characters where found
            $newFileName = $item.Name
            Matches $illegalChars | ForEach-Object {
                Write-Host $type $item.FullName has the illegal character $_.Value -ForegroundColor Red
                #These characters may be used on the file system but not SharePoint
                if ($_.Value -match "&") { $newFileName = ($newFileName -replace "&", "and") }
                if ($_.Value -match "{") { $newFileName = ($newFileName -replace "{", "(") }
                if ($_.Value -match "}") { $newFileName = ($newFileName -replace "}", ")") }
                if ($_.Value -match "~") { $newFileName = ($newFileName -replace "~", "-") }
                if ($_.Value -match "#") { $newFileName = ($newFileName -replace "#", "") }
                if ($_.Value -match "%") { $newFileName = ($newFileName -replace "%", "") }
            }
           
            #Check for start, end and double periods
            if ($newFileName.StartsWith(".")) { Write-Host $type $item.FullName starts with a period -ForegroundColor red }
            while ($newFileName.StartsWith(".")) { $newFileName = $newFileName.TrimStart(".") }
            if ($newFileName.EndsWith(".")) { Write-Host $type $item.FullName ends with a period -ForegroundColor Red }
            while ($newFileName.EndsWith("."))   { $newFileName = $newFileName.TrimEnd(".") }
            if ($newFileName.Contains("..")) { Write-Host $type $item.FullName contains double periods -ForegroundColor red }
            while ($newFileName.Contains(".."))  { $newFileName = $newFileName.Replace("..", ".") }
           
            #Fix file and folder names if found and the Fix switch is specified
            if (($newFileName -ne $item.Name) -and ($Fix))
            {
                Rename-Item $item.FullName -NewName ($newFileName)
                Write-Host $type $item.Name has been changed to $newFileName -ForegroundColor Blue
            }
        }
    }
}
0
 

Author Comment

by:frugalmule
ID: 40510637
where should I put it?
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40510731
NO POINTS:
save the following as Check-IllegalCharacters.ps1
Doesn't matter where you save it

  <#
            .AUTHORS
            RezSupport
            David Johnson (ve3ofa)

            .VERSION
            1.01

            .FILENAME
          Save as "Check-IllegalCharacters.ps1"
           
           .SYNOPSIS 
          Checks and Optionally Fixes Files with Illegal Characters
          or FilePaths > 127 Characters

           .DESCRIPTION
          The Check-IllegalCharacters.ps1 script checks the path given
           for files with illegal characters and filelenghts greater than 
           127 characters for input to Onedrive
              
           .PARAMETER Path
           Specifies the path to the Root Directory to Search

           .PARAMETER -Fix
           Will Fix files with Illegal Filenames

           .PARAMETER -Verbose
           Will Give Verbose Output 
           
           .INPUTS
           None. You cannot pipe objects to Check-IllegalCharacters.ps1.

           .OUTPUTS
           None. Check-IllegalCharacters.ps1 does not generate any output.

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path c:\

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path C:\Data\ -Fix

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path C:\Data\ - Verbose
           #>


[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
        [string]$Path,
        [Parameter(Mandatory=$False)]
        [switch] $Fix
        )       
    if (test-path $path) {
    Write-Host Checking files in $Path, please wait...
    #Get all files and folders under the path specified
    $items = Get-ChildItem -Path $Path -Recurse
    foreach ($item in $items)
    {
        #Check if the item is a file or a folder
        if ($item.PSIsContainer) { $type = "Folder" }
        else { $type = "File" }
       
        #Report item has been found if verbose mode is selected
        if ($Verbose) { Write-Host Found a $type called $item.FullName }
       
        #Check if item name is 128 characters or more in length
        if ($item.Name.Length -gt 127)
        {
            Write-Host $type $item.Name is 128 characters or over and will need to be truncated -ForegroundColor Red
        }
        else
        {
            #Got this from http://powershell.com/cs/blogs/tips/archive/2011/05/20/finding-multiple-regex-matches.aspx
            $illegalChars = '[&{}~#%]'
            filter Matches($illegalChars)
            {
                $item.Name | Select-String -AllMatches $illegalChars |
                Select-Object -ExpandProperty Matches
                Select-Object -ExpandProperty Values
            }
           
            #Replace illegal characters with legal characters where found
            $newFileName = $item.Name
            Matches $illegalChars | ForEach-Object {
                Write-Host $type $item.FullName has the illegal character $_.Value -ForegroundColor Red
                #These characters may be used on the file system but not SharePoint
                if ($_.Value -match "&") { $newFileName = ($newFileName -replace "&", "and") }
                if ($_.Value -match "{") { $newFileName = ($newFileName -replace "{", "(") }
                if ($_.Value -match "}") { $newFileName = ($newFileName -replace "}", ")") }
                if ($_.Value -match "~") { $newFileName = ($newFileName -replace "~", "-") }
                if ($_.Value -match "#") { $newFileName = ($newFileName -replace "#", "") }
                if ($_.Value -match "%") { $newFileName = ($newFileName -replace "%", "") }
            }
           
            #Check for start, end and double periods
            if ($newFileName.StartsWith(".")) { Write-Host $type $item.FullName starts with a period -ForegroundColor red }
            while ($newFileName.StartsWith(".")) { $newFileName = $newFileName.TrimStart(".") }
            if ($newFileName.EndsWith(".")) { Write-Host $type $item.FullName ends with a period -ForegroundColor Red }
            while ($newFileName.EndsWith("."))   { $newFileName = $newFileName.TrimEnd(".") }
            if ($newFileName.Contains("..")) { Write-Host $type $item.FullName contains double periods -ForegroundColor red }
            while ($newFileName.Contains(".."))  { $newFileName = $newFileName.Replace("..", ".") }
           
            #Fix file and folder names if found and the Fix switch is specified
            if (($newFileName -ne $item.Name) -and ($Fix))
            {
                Rename-Item $item.FullName -NewName ($newFileName)
                Write-Host $type $item.Name has been changed to $newFileName -ForegroundColor Blue
            }
        }
    }
 }
 else {
 Write-host("Path " + $path + " Does Not Exist")
 }

Open in new window

0
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 

Author Comment

by:frugalmule
ID: 40512349
Thanks very much.  Still having some issues http://screencast.com/t/BHGDV60yhQ
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40512465
you have to execute the file using powershell
0
 

Author Comment

by:frugalmule
ID: 40512500
I apologize. Can you tell me how I would execute it?
0
 

Assisted Solution

by:rezsupport
rezsupport earned 84 total points
ID: 40512963
Open PS as an admin (right click and click run as administrator) browse to the location of the ps1 file you just created and type the first few letters of the file name and hit tab. Then hit enter to execute.
0
 

Author Comment

by:frugalmule
ID: 40517313
Thanks for the suggestion.  I did run as admin but got this error.

http://screencast.com/t/sGVHVpqJikg
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40518834
Set-ExecutionPolicy RemoteSigned
accept the prompt to change the execution policy from restricted
now run the script
0
 

Author Comment

by:frugalmule
ID: 40519194
can I restrict the policy any further where it will still allow the script to run for me the user only
0
 

Author Comment

by:frugalmule
ID: 40534896
I did run the Set-ExcecutionPolicy RemoteSigned successfully.  After that, I ran into some trouble as shown here http://screencast.com/t/KhywtwCdQC.  I saved the file as a ps1 file, right clicked and said run in powershell.  Not much luck.
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40535487
it is asking for a starting directory (path)
0
 

Author Comment

by:frugalmule
ID: 40535946
I'm confused.  If you could post the command that I should put in and where, that would be great.  Do right click the file to run it?  If it wants the path to OneDrive, it is actually C:\Users\Ted\SkyDrive
0
 

Author Comment

by:frugalmule
ID: 40536801
Thanks for the help.  I appreciate it very much.  These are the steps I took but still get the same error.

http://screencast.com/t/W8z5E6yGD
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40537016
Added some error checking
http://screencast.com/t/6D4t7j3sqL
  <#
            .AUTHORS
            RezSupport
            David Johnson (ve3ofa)

            .VERSION
            1.01
            1.02 Added Error Checking for any File Exception
            .FILENAME
          Save as "Check-IllegalCharacters.ps1"
           
           .SYNOPSIS 
          Checks and Optionally Fixes Files with Illegal Characters
          or FilePaths > 127 Characters

           .DESCRIPTION
          The Check-IllegalCharacters.ps1 script checks the path given
           for files with illegal characters and filelenghts greater than 
           127 characters for input to Onedrive
              
           .PARAMETER Path
           Specifies the path to the Root Directory to Search

           .PARAMETER -Fix
           Will Fix files with Illegal Filenames

           .PARAMETER -Verbose
           Will Give Verbose Output 
           
           .INPUTS
           None. You cannot pipe objects to Check-IllegalCharacters.ps1.

           .OUTPUTS
           None. Check-IllegalCharacters.ps1 does not generate any output.

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path c:\

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path C:\Data\ -Fix

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path C:\Data\ - Verbose
           #>


[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
        [string]$Path,
        [Parameter(Mandatory=$False)]
        [switch] $Fix
        )       
    if (test-path $path) {
    Write-Host Checking files in $Path, please wait...
    #Get all files and folders under the path specified
    
    $items = Get-ChildItem –Force –Recurse  -ErrorAction SilentlyContinue –ErrorVariable AccessDenied -Path $Path
    $AccessDenied | ForEach-Object {
        $_.TargetObject
        $_.Exception
    }
    
    foreach ($item in $items)
    {
        #Check if the item is a file or a folder
        if ($item.PSIsContainer) { $type = "Folder" }
        else { $type = "File" }
       
        #Report item has been found if verbose mode is selected
        if ($Verbose) { Write-Host Found a $type called $item.FullName }
       
        #Check if item name is 128 characters or more in length
        if ($item.Name.Length -gt 127)
        {
            Write-Host $type $item.Name is 128 characters or over and will need to be truncated -ForegroundColor Red
        }
        else
        {
            #Got this from http://powershell.com/cs/blogs/tips/archive/2011/05/20/finding-multiple-regex-matches.aspx
            $illegalChars = '[&{}~#%]'
            filter Matches($illegalChars)
            {
                $item.Name | Select-String -AllMatches $illegalChars |
                Select-Object -ExpandProperty Matches
                Select-Object -ExpandProperty Values
            }
           
            #Replace illegal characters with legal characters where found
            $newFileName = $item.Name
            Matches $illegalChars | ForEach-Object {
                Write-Host $type $item.FullName has the illegal character $_.Value -ForegroundColor Red
                #These characters may be used on the file system but not SharePoint
                if ($_.Value -match "&") { $newFileName = ($newFileName -replace "&", "and") }
                if ($_.Value -match "{") { $newFileName = ($newFileName -replace "{", "(") }
                if ($_.Value -match "}") { $newFileName = ($newFileName -replace "}", ")") }
                if ($_.Value -match "~") { $newFileName = ($newFileName -replace "~", "-") }
                if ($_.Value -match "#") { $newFileName = ($newFileName -replace "#", "") }
                if ($_.Value -match "%") { $newFileName = ($newFileName -replace "%", "") }
            }
           
            #Check for start, end and double periods
            if ($newFileName.StartsWith(".")) { Write-Host $type $item.FullName starts with a period -ForegroundColor red }
            while ($newFileName.StartsWith(".")) { $newFileName = $newFileName.TrimStart(".") }
            if ($newFileName.EndsWith(".")) { Write-Host $type $item.FullName ends with a period -ForegroundColor Red }
            while ($newFileName.EndsWith("."))   { $newFileName = $newFileName.TrimEnd(".") }
            if ($newFileName.Contains("..")) { Write-Host $type $item.FullName contains double periods -ForegroundColor red }
            while ($newFileName.Contains(".."))  { $newFileName = $newFileName.Replace("..", ".") }
           
            #Fix file and folder names if found and the Fix switch is specified
            if (($newFileName -ne $item.Name) -and ($Fix))
            {
                Rename-Item $item.FullName -NewName ($newFileName)
                Write-Host $type $item.Name has been changed to $newFileName -ForegroundColor Blue
            }
        }
    }
 }
 else {
 Write-host("Path " + $path + " Does Not Exist")
 }
# SIG # Begin signature block
# MIINGAYJKoZIhvcNAQcCoIINCTCCDQUCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUP4Chs1Fb2XxmcAyA6UEi8rvt
# /xGgggpaMIIFIjCCBAqgAwIBAgIQAupQIxjzGlMFoE+9rHncOTANBgkqhkiG9w0B
# AQsFADByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYD
# VQQLExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhEaWdpQ2VydCBTSEEyIEFz
# c3VyZWQgSUQgQ29kZSBTaWduaW5nIENBMB4XDTE0MDcxNzAwMDAwMFoXDTE1MDcy
# MjEyMDAwMFowaTELMAkGA1UEBhMCQ0ExCzAJBgNVBAgTAk9OMREwDwYDVQQHEwhI
# YW1pbHRvbjEcMBoGA1UEChMTRGF2aWQgV2F5bmUgSm9obnNvbjEcMBoGA1UEAxMT
# RGF2aWQgV2F5bmUgSm9obnNvbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
# ggEBAM3+T+61MoGxUHnoK0b2GgO17e0sW8ugwAH966Z1JIzQvXFa707SZvTJgmra
# ZsCn9fU+i9KhC0nUpA4hAv/b1MCeqGq1O0f3ffiwsxhTG3Z4J8mEl5eSdcRgeb+1
# jaKI3oHkbX+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QXNzdXJlZCBJRCBDb2RlIFNpZ25pbmcg
# Q0ECEALqUCMY8xpTBaBPvax53DkwCQYFKw4DAhoFAKB4MBgGCisGAQQBgjcCAQwx
# CjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcCAQQwHAYKKwYBBAGC
# NwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYEFGgbs9EWp7NO+aFG
# mhxtwHAWf+WAMA0GCSqGSIb3DQEBAQUABIIBALe0kGB/GPbwfsvuUToffqfkIazu
# 1bKzXnknhWlYGrmrubhRYAWbmoIh6xnQP16aNYVg/dMk5RuWwg2+jV9w4mGf3GGz
# ztjHKH9A8/DzWjlAonSAXZ6EwmFGROf68BbgtYdDcdp0kAVHu2rYihS+Ia2os9r1
# MJ9m/ui/l/pUwXDQbhZirDh1wWk3cVOjZHqfS3C0w2ORaYRTiu0vawD/2u3jlt7N
# KlbyYwzUEB0VVqjIfGMdRTitm/PELYsfGDaI/nx5eUYv5jTqmFBqNFzeeBCHJFuW
# r5yS96GymJwXh3kVL0iDnLCQNiFzaBMDE/J5lp4OBEFj7++tVjnTFi4ZWrc=
# SIG # End signature block

Open in new window

0
 

Author Comment

by:frugalmule
ID: 40537181
Thanks for the help.  I appreciate it very much.  These are the steps I took but still get the same error.

http://screencast.com/t/mqK3HjAn
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40539574
Changed the write-host to write-output this way you can pipe the output to a file i.e.
from a powershell command prompt (start powershell)

.\Check-IllegalCharacters.ps1  -path c:\whatever  > output.txt
http://www.screencast.com/t/Ci9DLY78R4
  <#
            .AUTHORS
            RezSupport
            David Johnson (ve3ofa)

            .VERSION
            1.01
            1.02 Added Error Checking for any File Exception
            1.03 Replaced Write-Output with write-output and added proper
                 atribution http://get-spscripts.com/2011_11_01_archive.html
            .FILENAME
          Save as "Check-IllegalCharacters.ps1"
           
           .SYNOPSIS 
          Checks and Optionally Fixes Files with Illegal Characters
          or FilePaths > 127 Characters

           .DESCRIPTION
          The Check-IllegalCharacters.ps1 script checks the path given
           for files with illegal characters and filelenghts greater than 
           127 characters for input to Onedrive
              
           .PARAMETER Path
           Specifies the path to the Root Directory to Search

           .PARAMETER -Fix
           Will Fix files with Illegal Filenames

           .PARAMETER -Verbose
           Will Give Verbose Output 
           
           .INPUTS
           None. You cannot pipe objects to Check-IllegalCharacters.ps1.

           .OUTPUTS
           None. Check-IllegalCharacters.ps1 does not generate any output.

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path c:\

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path C:\Data\ -Fix

           .EXAMPLE
           C:\PS> .\Check-IllegalCharacters.ps1 -path C:\Data\ - Verbose
           #>


[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
        [string]$Path,
        [Parameter(Mandatory=$False)]
        [switch] $Fix
        )       
    if (test-path $path) {
    $output = "Checking files in "+$path+" ...please wait..."
    Write-Output $output
    #Get all files and folders under the path specified
    
    $items = Get-ChildItem –Force –Recurse  -ErrorAction SilentlyContinue –ErrorVariable AccessDenied -Path $Path
    $AccessDenied | ForEach-Object {
        $_.TargetObject
        $_.Exception
    }
    
    foreach ($item in $items){
        #Check if the item is a file or a folder
        if ($item.PSIsContainer) { $type = "Folder" }
        else { $type = "File" }
       
        #Report item has been found if verbose mode is selected
        if ($Verbose) { 
            Write-Verbose (Found a $type called $item.FullName) 
        }
       
        #Check if item name is 128 characters or more in length
        if ($item.Name.Length -gt 127)
        {
        $output =$type +" " + $item.Name + " is 128 characters or over and will need to be truncated "
            Write-Output $output

        }
        else
        {
            #Got this from http://powershell.com/cs/blogs/tips/archive/2011/05/20/finding-multiple-regex-matches.aspx
            $illegalChars = '[&{}~#%]'
            filter Matches($illegalChars)
            {
                $item.Name | Select-String -AllMatches $illegalChars |
                Select-Object -ExpandProperty Matches
                Select-Object -ExpandProperty Values
            }
           
            #Replace illegal characters with legal characters where found
            $newFileName = $item.Name
            Matches $illegalChars | ForEach-Object {
                $output = $type+" "+$item.FullName+ " has the illegal character "+ $_.Value
                Write-Output $output
                #These characters may be used on the file system but not SharePoint
                if ($_.Value -match "&") { $newFileName = ($newFileName -replace "&", "and") }
                if ($_.Value -match "{") { $newFileName = ($newFileName -replace "{", "(") }
                if ($_.Value -match "}") { $newFileName = ($newFileName -replace "}", ")") }
                if ($_.Value -match "~") { $newFileName = ($newFileName -replace "~", "-") }
                if ($_.Value -match "#") { $newFileName = ($newFileName -replace "#", "") }
                if ($_.Value -match "%") { $newFileName = ($newFileName -replace "%", "") }
            }
           
            #Check for start, end and double periods
            if ($newFileName.StartsWith(".")) 
                { 
                $output = $type+" "+ $item.FullName+" starts with a period"
                Write-Output $output
                }
            while ($newFileName.StartsWith(".")) 
                { 
                $newFileName = $newFileName.TrimStart(".") 
                }
            if ($newFileName.EndsWith(".")) 
                { 
                $output = $type+" "+$item.FullName+" ends with a period"
                Write-Output  $output
                }
            while ($newFileName.EndsWith("."))   { 
                $newFileName = $newFileName.TrimEnd(".") 
                }
            if ($newFileName.Contains("..")) 
                { 
                $output = $type+" "+$item.FullName+" contains double periods"
                Write-Output $output
                }
            while ($newFileName.Contains(".."))  
                { 
                $newFileName = $newFileName.Replace("..", ".") 
                }
           
            #Fix file and folder names if found and the Fix switch is specified
            if (($newFileName -ne $item.Name) -and ($Fix)){
                Rename-Item $item.FullName -NewName ($newFileName)
                $output = $type+" "+$item.Name+" has been changed to "+$newFileName
                Write-Output $output
                }
            }
        }
    }
 
 
 else {
 Write-Output("Path " + $path + " Does Not Exist")
 }
# SIG # Begin signature block
# MIINGAYJKoZIhvcNAQcCoIINCTCCDQUCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUP4Chs1Fb2Xxm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bhZirDh1wWk3cVOjZHqfS3C0w2ORaYRTiu0vawD/2u3jlt7N
# KlbyYwzUEB0VVqjIfGMdRTitm/PELYsfGDaI/nx5eUYv5jTqmFBqNFzeeBCHJFuW
# r5yS96GymJwXh3kVL0iDnLCQNiFzaBMDE/J5lp4OBEFj7++tVjnTFi4ZWrc=
# SIG # End signature block
 

Open in new window

0
 

Author Comment

by:frugalmule
ID: 40542429
I see now.  I though you were working on something to fix the illegal characters so that the sync would work.
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40542442
from a powershell command prompt or the powershell ISE
check-illegalcharacters.ps1 -path c:\abc -fix
type help check-illegalcharacters.ps1 to see the syntax
0
 

Author Comment

by:frugalmule
ID: 40542499
I tried the latest code again with the -fix switch.  Still no luck getting it to work.  Here is the syntax I used as well as the error.Capture
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40542511
that means that check-illegalcharacters.ps1 is not in that directory
c:\test\check-illegalcharacters.ps1 -path c:\users\ted\skydrive -fix
0
 

Author Comment

by:frugalmule
ID: 40542526
Still no luck using that path either http://screencast.com/t/n0D66ZCypydZ.
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40542629
what if you type "check" and then press the tab key
the c:\test\ is the location that you saved the .ps1 file.
0
 

Author Comment

by:frugalmule
ID: 40542661
yes to the second line

here is the result of check http://screencast.com/t/tD4rUqeCNK31
0
 
LVL 80

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 416 total points
ID: 40542668
right click on the powershell ise or select powershell ise (run as administrator) once it comes up
set-executionpolicy remotesigned  (accept the prompt)
0
 

Author Comment

by:frugalmule
ID: 40543101
still no luck for me
0
 

Author Comment

by:frugalmule
ID: 40548325
It seems we are having difficulty connecting.
0
 

Author Comment

by:frugalmule
ID: 40697031
now we can't even see the sync status anymore ??
0
 

Author Comment

by:frugalmule
ID: 40718994
We got past this and are no longer receiving the long file name error.  Now we still can't get the upload to finish though Here is the new question >> http://www.experts-exchange.com/Networking/Cloud_Computing/Q_28654182.html
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Concerto Cloud Services, a provider of fully managed private, public and hybrid cloud solutions, announced today it was named to the 20 Coolest Cloud Infrastructure Vendors Of The 2017 Cloud  (http://www.concertocloud.com/about/in-the-news/2017/02/0…
This video teaches viewers how to encrypt an external drive that requires a password to read and edit the drive. All tasks are done in Disk Utility. Plug in the external drive you wish to encrypt: Make sure all previous data on the drive has been …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question