Search User Login Menu
Tools
Close

Respect the Graph!

Respect the Graph!

A Case Study in the value of the MS Graph and a nifty Powershell trick.

We recently had a patient that had a growth spreading in some of their Teams sites, caused by careless mishandling of content during initial migration to Ofice365.  The model having been set, was then propagated by the users of that site, as well as users becoming entrenched with the migrated documents in their daily work flow.  The end result was a plague of document libraries, where there should have been a library with a bunch of folders; and users who have been working with the documents from the {improper} migrated locations.  Users don't generally like to have to go and re-map all of their document links after a drastic change in location, enter MSGraph. 

IF done properly.... While the users will still have to get used to a new location for finding documents to work with, or where to put new documents, the files that they have been working with will not have to be re-found!  Take, for example, a Word document that a user has been working with every day for a week, using the Recent Documents list to open it every morning, now it has to be moved to a new location.  Traditionally, this would make all of the recent documents links invalid.  In Office365, with MSGraph and the MoveTo command, recently documents links remain intact! (withing the MSOffice world, at least ;) ).  If you create copies and delete the original, this would not work, but using the MoveTo command, the document's MSGraph ID stays the same and Office is able to re-connect-the-dots and find/open the document and update the location in the recently opened documents list. 

The MoveTo command is available to all users, and allows a user to move a document to any location that they have access to in the tennant;  Team sites, OneDrive, etc.  If the problem is a wide ranging structural plague, that requires radical code-otherapy treatment, then the Admin can also make use of the MoveTo command in PowerShell.  It can be used with individual files, or entire folders. 

You may be asking yourself now (or possibly after moving a bunch of documents), what happens to the document metadata for all of my custom columns?  This was tested:  

  • Source Library with User Column, Destination Library standard columns only:  The document was moved, the metadata does not show; If the document is moved back to the original library, the column data is still in-tact. 
  • Site column is added to the Destination Library after the document move:  The metadata does not show; If the document is moved back to the original library, the column data is still in-tact;
  • Site column is added to the Destination Library before the document move:  The metadata is preserved and shows. 

Document Library Example:

(a file and a folder selected)

*Bill Jones is obviously an alias used to protect privacy.

 

Powershell Example:

  • For File Objects:

            $SourceFile.MoveTo($TargetFileURL, [Microsoft.SharePoint.Client.MoveOperations]::Overwrite)
            $SourceFile.Context.ExecuteQuery()

 

  • Or For Folder Objects:


    *Requires that the feature for Push Notifications is enabled for the site.  If it is not, see below.
                $SubFolder.MoveTo($TargetFolderURL + '/' + $SubFolder.Name)
                $SubFolder.Context.ExecuteQuery()

 

*To enable Push Notifications on the site (if you get an error running the script for moving folders)  Run the following command in a current powershell for sharepoint installation:

Connect-PnPOnline https://myorg.sharepoint.com
Enable-PnPFeature -Identity 41e1d4bf-b1a2-47f7-ab80-d5d6cbba3092 -Scope Site

 

If you have any questions about using the MoveTo command, feel free to send your questions or make an appointment for a consultation via email: doctor@doctorsharepoint.com 

Print
11002 Rate this article:
4.0

Theme picker

Back To Top