OneDrive for Business Admin Tools

This tool aims to take care of the following tasks: Block or unblock access to OneDrive for Business sites Grant a secondary user rights over a OneDrive for Business site  Revoke a secondary user's rights over a OneDrive for Business site  Create a folder in all OneDrive for Bus

 
 
 
 
 
4.3 Star
(3)
3,440 times
Add to favorites
Office 365
8/2/2019
E-mail Twitter del.icio.us Digg Facebook
  • Syntax
    1 Posts | Last post January 29, 2020
    • I can't seem to get this to work.  I run the command below and it does not delete the folder and nothing is in the log.
      
       .\OneDriveForBusinessAdmin.ps1 -Credential (Get-Credential) -GrantPermissions -GrantPermissionsTo admin@tenant.onmicrosoft.com -FolderToDelete test -confirm -identity user@domain.com
  • Delete file pattern and personal sites to check
    1 Posts | Last post January 29, 2020
    • Hi,
      
      Thanks for the script, it was a lifesaver for remove a lot of files by it's extension. 
      
      I would like to ask if there's a way to use the DeleteFilePattern and read a csv to filter the sites that must be check to delete any coincidence instead of delete in all sites of OneDrive.
  • Folders to remove
    3 Posts | Last post September 20, 2019
    • Hi,
      
      Could you pls provide detailed steps to delete the folders from ODFB. I have tried your script but it is not working for me.
      
      Thanks in advance.
      
      Thanks,
      SK 
    • Make sure you have granted yourself access to the OD4B sites in question.
    • The script is not deleting any files.  It only grants permission. 
  • Some comments
    2 Posts | Last post August 02, 2019
    • 
      Hi, thanks for the script! I have a few remarks.
      
      1) There is still 1 reference to "FolderToRemove", even though the function is now called "FolderToDelete". Please update the description.
      
      2) The indents inside function RemoveFolder are misleading (the opening brackets do not have the same indent as the closing brackets).
      
      3) It seems we can find and delete folders only at the root level.
      ($allFolders = $docList.RootFolder.Folders)
      
      4) Deleting a folder with contents will not work if you have an active retention policy on this OneDrive. See here https://answers.microsoft.com/en-us/msoffice/forum/all/why-cant-i-delete-folders-in-onedrive/7549c238-53ef-4f55-bf1d-b081a5eed3e5
      
      You'd have to recursively delete any contents (files and folders).
      
      5) Some functions do not work when the document library title is non-English. For example, German "Dokumente".
      Is there a way to make this dynamic?
      Affected lines: 
      $personalWeb.Lists.GetByTitle
      $ClientContextSource.Web.Lists.GetByTitle
      
      6) It took me a minute to figure out I would have to use -Confirm switch to actually delete something. The console just showed "No action taken". Well, I might be expected to read the complete description before running the script, but 
      - the "No action taken." could be updated to something more obvious like "No action taken, use -Confirm parameter to perform the deletion".
      - a short reference to -Confirm parameter inside the FolderToDelete description would be nice. Like the reference to GrantPermissions parameter.
    • Thanks for taking the time to make the comments and suggestions!
      1. I have fixed this.
      2. Ugh. I can totally see that being frustrating. I've updated that as well.
      3. Yes. When I first created this, it was really to help my customers deal with the "Shared with Everyone" folder that used to be turned on by default.  I'll look into making it recursive (or using a regex match to be even more specific).
      4. Interesting. I hadn't explored those conditions.  The .DeleteObject() method is pretty quick when it comes to the folder level; having to cycle through files will definitely take some time. I've got a few ideas to work around it (so we don't take unnecessary amounts of time), so I'll have to start testing those to make sure I have a solid answer.
      5. I haven't ever seen that, likely because I'm only an English-speaker.  If you have a suggestion on how to overcome it, I'd love to hear it.
      6. I took this suggestion and implemented it.
  • Delete specific file
    1 Posts | Last post February 07, 2019
    • Is there a way to make the script delete specific files?  Fore example I have a list of files on users OneDrives exported from the Compliance Center. I can use file names of those files as pasterns and feed them to this script but I rather point to a specific file instead of searching by file name.