Move files & folders to Sharepoint 2010

Published by Joe on November 2nd, 2011 - in Server, Web

Lately I’ve been migrating some customers to Office 365.

One of them wanted to migrate their current file structure to sharepoint. Before disposing of their current file server.

Turns out it was quit allot of documents so a manual upload was not an option…

 

I tried mapping the sharepoint library as a network drive and copy the content but this resulted in many errors about too long filenames and invalid characters.

So I searched the web and found this great powershell script that will rename all the failing maps and files for me.

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
                }
            }
        }
    }

 

Paste this in your PowerShell and add

Check-IllegalCharacters -Path C:\YourFolder -Fix

Run it without the -Fix option if you just want a list of files and folders to be renamed.

 

Once this is done you just need to copy the content to your document library. I mapped the library as network drive S: (described http://hitechstorm.com/?p=24) and then used Robocopy to move my files.

 

This is the command I used: robocopy C:\YourFolder S:\ /E /MOVE /R:2 /LOG:C:\Users\MyUser\Desktop\RobocopyToSharepoint.txt

This will actually move the files and folders to the sharepoint library removing it from my HDD. Retry twice if it fails on a file then move on. And also post the results in a textfile on my Desktop.

 

PowerShell script found on http://get-spscripts.com/ <–Great site

 

Map sharepoint to network drive

Published by Joe on October 13th, 2011 - in Server, Web

I have a sharepoint running on https and I wanted to map it as a network drive. Easier said than done but after som tweaking I found the way to do it.

 

Say the url to my sharepoint document library that I want to map is https://sharepoint.hitechstorm.com/documents

I need to map the following adress: \\sharepoint.hitechstorm.com@SSL\DavWWWRoot\Documents

 

To break it down, \\<insert your domain here>@SSL\DavWWWRoot\ <– Will map the root of your sharepoint

Warning: session_start() [function.session-start]: Cannot send session cache limiter

Published by Joe on July 4th, 2011 - in Web

After moving a Joomla site I got these wierd error messages even though I had not modified anything but the configuration.php file.

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /storage/content/xxxxx/configuration.php:1) in /storage/content/xxxxx/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information – headers already sent by (output started at /storage/content/xxxxx/configuration.php:1) in /storage/content/xxxxx/libraries/joomla/session/session.php on line 426

 

Fixing this error is very simple. Just open your configuration.php file with notepad, choose save as and change the encoding to ANSI.

Klick save and overwrite the current configuration.php with the file you just saved.

Windows 7 SP1 installation fails with error c0000034

Published by Joe on June 9th, 2011 - in Client

Iv’e run into this error a couple of times. This is how you get it working:

  • Reboot your computer
  • Lauch the startup repair
  • As soon as the startup repair launches click cancel
  • An error message will show, click on don’t send
  • Click on view advanced options for recovery and support
  • Start the Command Prompt
  • Run %windir%\system32\notepad.exe
  • When notepad is launched press Ctrl+O or go to File -> Open
  • In filename type C:\Windows\winsxs\*.* and press enter
  • Find the file pending.xml and make a copy of it (just in case something goes wrong. Then we can use the copy to start over)
  • Now open the original file pending.xml (This is a very large file, working it will be slow)
  • Press Ctrl + F and search for 0000000000000000.cdf-ms
  • Delete the following code (If yours looks different just delete from the first tag containing <Checkpoint/> to the last tag containing 0000000000000000.cdf-ms

<Checkpoint/>
<DeleteFile path=”\SystemRoot\WinSxS\FileMaps\_0000000000000000.cdf-ms”/>
<MoveFile source=”\SystemRoot\WinSxS\Temp\PendingRenames\e56db1db48d4cb0199440000b01de419._0000000000000000.cdf-ms” destination=”\SystemRoot\WinSxS\FileMaps\_0000000000000000.cdf-ms”/>

  • When this is done, save your file and reboot your computer. Now it should work!

Lost domain admin password on Server 2008 / 2008R2

Published by Joe on June 8th, 2011 - in Server

The strangest thing happened to me the other day. I installed some updates on a SBS2011 and after a reboot the admin password didn’t work. After some searching in the web I found this extremely simple solution.

  • Insert your Windows installation CD
  • Boot from DVD
  • Choose your desired language
  • Choose option “Repair your computer”.
  • Choose your installation. Click next
  • Start command prompt.
  • Navigate to your system drive (sometimes it changes the drive letter starting at D:)
  • CD D:\Windows\System32
  • MOVE Utilman.exe Utilman.exe.bak
  • COPY Cmd.exe Utilman.exe
  • Reboot the server
  • At the login screen, press Windows button + U, this will open cmd.exe
  • NET USER <your admin account> <new password>
  • Login
  • Don’t forget to restore utilman.exe by running the command MOVE Utilman.exe.bak Utilman.exe

For a video tutorial check http://www.youtube.com/watch?v=Ar-VoO9ogHc

Tested and working on Windows Server 2008 and Windows Server 2008 R2

© Copyright Hitechstorm.com 2011-. All rights reserved.