Move SharePoint Online Files with PowerShell

  Рет қаралды 26,791

Shane Young

Shane Young

Күн бұрын

Learn how to manage and automate your SharePoint Online Document Libraries with the Patterns and Practices PowerShell. Cmdlets you will learn about and use include:
Get-PNPListItem
Copy-PNPFile
Remove-PNPFile
Move-PNPFile
Link to download the PowerShell from the video
sellfy.com/p/6...
Link to Password management for PowerShell video
• Learn to securely use ...
Link to install the Patterns and Practice PowerShell
• Install SharePoint Pat...
Link to intro to PowerShell Videos playlist
• All things Microsoft P...
For support or more information about PowerShell check out www.boldzebras.com
Edit notes: None. :)

Пікірлер: 78
@nickp9645
@nickp9645 3 жыл бұрын
great video as always. Most of this is still relevant four years later. Thank you!
@ShanesCows
@ShanesCows 3 жыл бұрын
Thanks 😊
@svavark
@svavark 5 жыл бұрын
Thanks Shane. It's mid 2019 and this is still valuable information. Thanks.
@ShanesCows
@ShanesCows 5 жыл бұрын
Crazy isn’t it. 😀
@marianmosby7849
@marianmosby7849 4 жыл бұрын
i felt it when he said "but first our intro"
@ShanesCows
@ShanesCows 4 жыл бұрын
😎
@Ricieree
@Ricieree 2 жыл бұрын
Hello Shane, excellent video, see if you can help me, I need to copy all the files from an office 365 e1 account of this user's onedrive (only files, emails I do otherwise) to another account to a specific folder as an example Backup contributor X, do you have any other videos or documentation that can guide me in this copy via power shell?
@leandersonsc
@leandersonsc 4 жыл бұрын
Congrats for the tutorial Shane! Do you know if have some way to copy files from Sharepoint to local machine using PowerShell?
@ShanesCows
@ShanesCows 4 жыл бұрын
Yes, you could adapt this script to save to the local file system
@zjweine
@zjweine 5 жыл бұрын
Great video and the step-by-step explanation finally sheds some light on somethings I did not understand before. Next step is build a script that reads a .csv and removes only those files listed in that .csv. :-)
@ShanesCows
@ShanesCows 5 жыл бұрын
Cool. I have a video that talks about working with CSVs and PowerShell if it helps. :)
@estherlopeznavarro6100
@estherlopeznavarro6100 2 жыл бұрын
Hi Shane, is it possible to copy or move files using Powershell PnP from one site collection document library to another site collection document library? Thanks! I love your videos!😀
@stvdp
@stvdp 7 жыл бұрын
Hi Shane,This was great! I learned some new things here! And thanks for all your help with the script. Looking forward to the next video,Michael McCabeNew York
@ShanesCows
@ShanesCows 7 жыл бұрын
Thanks, Michael! It was great working for you. I think you will really enjoy the next video where I take the next step and start moving the metadata.
@mgregoire78
@mgregoire78 6 жыл бұрын
Hi Shane, thanks for the great work you're doing with these videos. I've been trying to use the samples from this tutorial to build a script, but in my case I need to move files to a folder in the target library and I'm struggling with that. If I add the folder to the target url (/library/folder/document.doc) I get an error that I can't use special characters in the file name. I'm assuming powershell thinks that "folder/document.doc" is in fact all file name and doesn't treat this as a folder. Could you shed any light on how I can move files to a folder?
@ShanesCows
@ShanesCows 6 жыл бұрын
Add the folder to the path not the file name.
@mgregoire78
@mgregoire78 6 жыл бұрын
Awesome. Thanks for the reply Shane, I've managed to copy the files to the correct folder. Now my next challenge, if I try changing the metadata using the CAML from your follow-up video to this one, I always get the item if of the rootfolder of the document, not the id of the document itself. I've been thinking I need to make the CAML recursive but so far without any luck. Could you help me out, or point me in the right direction? As always your wisdom is greatly appreciated.
@mgregoire78
@mgregoire78 6 жыл бұрын
I 'fixed' this issue by copying the file to the root folder first, then get the id, and then move it to the correct folder. The ID will remain the same in the move action. It's not very elegant, but it works.
@xCTron
@xCTron 6 ай бұрын
Hey Shane, working on a massive data move from one SP Library Sub Folder to another, would this work for a subfolder into another Doc Library? Circa 22million files with daily uploads!
@ShanesCows
@ShanesCows 6 ай бұрын
Yes, it should. Might want to keep an eye on it with that many files but mechanically, all of the pieces are there.
@sribalajispaceship
@sribalajispaceship 3 жыл бұрын
Hi Shane. Trying to copy the attachments from sharepoint to local drive. Can you do a video on that?
@ShanesCows
@ShanesCows 3 жыл бұрын
Yikes, I have never done that before. Sorry
@MT-nw3qh
@MT-nw3qh 2 жыл бұрын
hi shane so how could i move multiple folders across multiple sharepoint sites all at once. is that possible?
@paulhloni4464
@paulhloni4464 Жыл бұрын
Awesome Video, can you do one where copying files from onedrive to sharepoint
@kendramedinanieves8627
@kendramedinanieves8627 5 жыл бұрын
Hi Shane, great video. Please, do you know how to get all duplicated files/documents in an online SharePoint site using pnp? Please help me
@ShanesCows
@ShanesCows 5 жыл бұрын
Sorry. Not aure
@tommylarsen4677
@tommylarsen4677 6 жыл бұрын
Hi Shane, thanks for your videos on using PnP to access Sharepoint Online. I have used them to put together a script to download files from Sharepoint to a local server, and the script itself works just fine. However, I have been struggling to get the script working from a scheduled task. The task is set to run as an account, for which the script runs perfectly when run manually from a powershell window. The account is also added to the "log on as a batch job" local security policy on the server. The account has sufficient access to Sharepoint - otherwise it would not do the desired file copies when run manually. When run from a scheduled task, I get the error message "Connect-PnPOnline: "Access is denied". By writing out the username property of the credential object, I see that the account name is returned when the script is run manually - but when run from a scheduled task, the username property is empty. So it's as if the script can't fetch the credentials in the credentials manager, when it is run from a scheduled task... Did you ever encounter this yourself, and do you happen to have a solution - or will it be impossible to make the PnP commands work in this scenario?
@ShanesCows
@ShanesCows 6 жыл бұрын
Tommy it will work. Credential Manager is per user. So if you put something in there as you and then run the scheduled task as a service account then it can’t find the credential. I have a video I talk a bit about this. I will find it and add it to another comment.
@ShanesCows
@ShanesCows 6 жыл бұрын
Automate your PowerShell scripts with Windows Task Scheduler kzbin.info/www/bejne/fYDOcqxoh9aFh80
@tommylarsen4677
@tommylarsen4677 6 жыл бұрын
Hi again, Shane I owe you some feedback on this. It was a bit embarrassing, because nothing you wrote was unknown to me. However, in the heat of the battle, I had failed to notice, that I had configured the task to run as another service account than the one I had planned to use. So thanks for helping the blind ! :-)
@allaniaarhus
@allaniaarhus 5 жыл бұрын
Great video, it's possible only to copy files if source file is newer than destination file?
@ShanesCows
@ShanesCows 5 жыл бұрын
Yes. Just have to write the logic to check the dates.
@BlakeOlson1980
@BlakeOlson1980 7 жыл бұрын
Thanks, Shane. Can you demo the process where the source list or library is on prem, and destination is SPO? In other words, I want to just grab an on prem list (and items) and move it to SPO.
@ShanesCows
@ShanesCows 7 жыл бұрын
Hey, Blake. That sounds like a great video. I will put it in the hopper. The other option is if you wanted it to move to the front of the line and for the content be based on exactly your needs I am happy to spin up the work through Bold Zebras. This is what I did for a few people, including Michael on this video. He and I worked together to write the script for his environment first. If that interests you shoot me an email.
@saket6
@saket6 3 жыл бұрын
How to Download SharePoint files to local system drive ? do you have video? Who will provide credentials for PnPOnlinePowerrshel? I need to download files from a SharePoint to my local disk. I have access to the SharePoint folder and files in my Org but my AD credentials are not working if write a PowerShel or VB Script to download a file. always getting Access Denied message. Could you please help me?
@kaklabe9406
@kaklabe9406 2 жыл бұрын
Hello, how can I move a page that's located on the root of my sharepoint site and move it to a site library with Powershell for Sharepoint ? Do you have any idea ? Any script ? Command ? Thanks :)
@jameswood6423
@jameswood6423 3 жыл бұрын
Is there any chance you can repost a link to the Powershell from the video as the link is not currently working, many thanks James
@ShanesCows
@ShanesCows 3 жыл бұрын
Hey James. I quit paying the hoster of that content. 😑 Sorry, I need to find a new home for it all but it was costing me money.
@jameswood6423
@jameswood6423 3 жыл бұрын
@@ShanesCows thanks for the update Shane, I tried to see if I could engage the guys at Powerapps911 for paying for a script to copy a ton of data between Sharepoint online site but apparently you guys are not doing that anymore, so I'm trying to workout the details of the script and csv file for myself. it is slow going but I'll get there.
@ShanesCows
@ShanesCows 3 жыл бұрын
@@jameswood6423 Email me shane at PowerApps911 and I will see if I can get the script from the archive for you. Also, I have a friend who still does this type of work I can intro you to if you would like?
@barbaragriffin8522
@barbaragriffin8522 6 жыл бұрын
Shane, Can you show how to connect to a list that is multiple levels deep. I attempted to use "/site/site/list" as syntax but I am getting Object reference not set to an instance of an object error.
@ShanesCows
@ShanesCows 6 жыл бұрын
There is a -web option you need to set.
@fernandomontoya4441
@fernandomontoya4441 5 жыл бұрын
Great Video I look forward to putting this knowledge to good use. Question what prerequisites are needed for these commands to work I think I have a permissions issue. I have an administrator Powershell open and the Connect-PnpOnline -url ...gives me the error "The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file..."
@fernandomontoya4441
@fernandomontoya4441 5 жыл бұрын
i may have resolved my own issue... I got errors when I ran the commands to install-module -name SharepointPnPPowerShellOnline "NuGet provider required..blah blah" had to go and manually download the PnP Cmdlets Now I see you have a video on that! kzbin.info/www/bejne/p57RmmOKptCheKc anyway thanks.
@ShanesCows
@ShanesCows 5 жыл бұрын
Glad you got it.
@alexandrasmith7523
@alexandrasmith7523 6 жыл бұрын
Hi Shane, I am looking to move all files from a SharePoint location to a folder on the C drive. I am able to move one specified file but not all of them. I can see how you can move files from one SharePoint location to another but it is possible to do what I require? Be aware that this script will be put on a scheduled task and the files will have new names each day so the filenames cannot be specified. Move all files from a SharePoint location to a folder on the C drive? Apologies if I have missed this in your tutorials. Thanks, Alexandra
@ShanesCows
@ShanesCows 6 жыл бұрын
Yes. Get the items from the list and then use get-pnpfile to download them.
@alexandrasmith7523
@alexandrasmith7523 6 жыл бұрын
Hi Shane, I'm glad it can be done! Have you got any examples of the scripts required please? I am failing to get it to work at the moment. Thanks, Alexandra
@lahernandezs
@lahernandezs 7 жыл бұрын
Thanks Shane! you are the best!
@drkamikaze1
@drkamikaze1 5 жыл бұрын
Hi, I'm using mov-pnp but I want to: display an error message or prompt user to overwrite file. How can I get this done?
@ShanesCows
@ShanesCows 5 жыл бұрын
Not sure.
@meme-bu4ud
@meme-bu4ud 6 жыл бұрын
Hi Shane, I am looking for way to move folders with lots of files from SPO to One Drive For business. is this possible. Any time when I use browser feature to move across it freeze in most of occasions, tried on all browser but same result, any suggestions, I have found some cool PS script to empty recycle bin, keeps giving errors from time to time but at least remove thousands of files in 5 min rather than hours via browser. Thanks
@ShanesCows
@ShanesCows 6 жыл бұрын
This video should do exactly what you want? I deleted your other comment for you and will email you.
@niranmanandhar8517
@niranmanandhar8517 6 жыл бұрын
Can we move the documents from one site collection to another site collection . Can't seem to do this and I am exhausted trying to find an answer from the general search.
@ShanesCows
@ShanesCows 6 жыл бұрын
Yes, but it is complicated. Sorry, don’t have any sample code to send you.
@mikesmith-knutsen4028
@mikesmith-knutsen4028 6 жыл бұрын
I'm curious about this myself. It would be great if I could move files/folders from one site collection to another, as that's a task I need to do at my company.
@frenske2002
@frenske2002 5 жыл бұрын
@@mikesmith-knutsen4028 I'm looking for some info regarding this issue also. Have you found any examples for that?
@mikesmith-knutsen4028
@mikesmith-knutsen4028 5 жыл бұрын
@@frenske2002 I didn't - I ended up having to pay for Sharegate to migrate the site collections, which isn't cheap of course.
@chaitanyavarma5597
@chaitanyavarma5597 5 жыл бұрын
I want to migrate sharepoint to sharepoint using powershell how to do, can you make a video about the topic
@ShanesCows
@ShanesCows 5 жыл бұрын
Most of the pieces are here already. Use the list PowerShell to copy lists.
@chaitanyavarma5597
@chaitanyavarma5597 5 жыл бұрын
@@ShanesCows Hi Shane, Thank you for the reply, Actually i am a beginner actually i want to migrate sharepoint online site collection to another sharepoint online using powershell, that site collection will be created in this next sharepoint online right. is it possible.
@harsh19dixit
@harsh19dixit 7 жыл бұрын
HI Shane I want to move Documents from SPO Doc library to local drive using PNP powershell but Move/Copy is asking for target URL , can you suggest ?
@ShanesCows
@ShanesCows 7 жыл бұрын
Get-PNPFile is what you want to use.
@harsh19dixit
@harsh19dixit 7 жыл бұрын
Thanks Shane PS:> Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -Path c:\temp -FileName company.spcolor this worked for me
@beerzo
@beerzo 3 жыл бұрын
Can anyone advise how i can restore all from the restore bin in 1 shot? Someone deleted all files.
@ShanesCows
@ShanesCows 3 жыл бұрын
Sorry I am not help. 😑
@richardcollins9862
@richardcollins9862 6 жыл бұрын
'Docs'? Confused from the start, how / where do you specify the Sharepoint Site collection/site/Library or List?
@ShanesCows
@ShanesCows 6 жыл бұрын
Sorry you have problems Richard. Let me try to help quickly. When you run the line Connect-PNPOnline that tells PowerShell what Site Collection you are in. Then at 4:40 you do get-pnplistitem. Docs is the name of the SharePoint lists you want to get documents from. If you do a get-pnplist you will see all of the lists in your web and their names. If you need to use a sub site then add -web for your subsite name. Doest that help?
@richardcollins9862
@richardcollins9862 6 жыл бұрын
Many thanks. Got it. Tried it, same site, used $targetLib = "catlib/" (without front /) as same site. Works great. Cheers, R
@ShanesCows
@ShanesCows 6 жыл бұрын
Awesome. Thanks for the follow up. :)
@zackannexstein2584
@zackannexstein2584 7 жыл бұрын
This is great, thanks Shane. Are there any other things to consider, like copying to a library SharePoint site in the same site collection or Different site collection? Nested folders? I've been working with a document library that is well over the 5000 item limit threshold, and have been working on breaking the data out into multiple libraries. Looking to automate document library creation based on a folder name in the document library, then copy the data over to that library, this is pointing me in the right direction. Also, Have you covered this scenario / possibly looking at it in the future? technet.microsoft.com/en-us/library/mt203923.aspx A general overview, it's the migration of local files to Azure Blob storage to SharePoint online document libraries. I'm honestly having a hard time finding any good guides on it. Hitting a few gotchyas related to special characters "-" in a library name is null.. trying to move each folder in my local share to a different library by grabbing the filename and trying to match that up to the document library URL. ps Personal preference - if you're showing a script i'd suggest showing it in ISE to see all of the commands - variables from start to finish, comments etc.
@ShanesCows
@ShanesCows 7 жыл бұрын
Thanks Zack. That is a lot feedback. I don't have any immediate answers but I will see what I can come up with.
@zackannexstein2584
@zackannexstein2584 7 жыл бұрын
Just wanted to give you an update. I figured it out using mainly documentation from Stack Exchange and Stack Overflow while referencing MS's poor documentation. I had a file share of projects (200+ folders) that I was tasked to move to SharePoint. Using Powershell I created a document library for each folder in SPO and uploaded contents of each folder into its document library. Definitely saved a lot time over dragging and dropping with throttled upload speeds and slow loading browser windows. The most time consuming parts were creating the libraries, matching the folder to the library (using get-pnplist.defaultviewurl) and learning how these migration cmdlets worked (and testing if they worked..) sharepoint.stackexchange.com/questions/207323/o365-onedrive-upload-data-via-azure stackoverflow.com/questions/40996811/upload-on-premises-content-to-sharepoint-online-how-to-retrieve-the-logs-using
@ShanesCows
@ShanesCows 7 жыл бұрын
That is awesome Zack! Thank you for the follow-up answers. Sorry, I was delayed. KZbin flagged you as spam but I fixed it. Thanks again. -Shane
@WeAreLight05
@WeAreLight05 7 жыл бұрын
When powershell asks for input like: List: How do I put two words together? LIke: "Yellow Documents"?
@WeAreLight05
@WeAreLight05 7 жыл бұрын
Nvm...
Work with Date & Time with PowerShell
16:45
Shane Young
Рет қаралды 59 М.
Copy, Move, Delete files with PowerShell
17:01
Shane Young
Рет қаралды 173 М.
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 122 МЛН
Я сделала самое маленькое в мире мороженое!
00:43
Кушать Хочу
Рет қаралды 4,8 МЛН
Wait for the last one 🤣🤣 #shorts #minecraft
00:28
Cosmo Guy
Рет қаралды 9 МЛН
Хасанның өзі эфирге шықты! “Қылмыстық топқа қатысым жоқ” дейді. Талғарда не болды? Халық сене ме?
09:25
Демократиялы Қазақстан / Демократический Казахстан
Рет қаралды 343 М.
Learn to securely use Passwords with PowerShell
18:13
Shane Young
Рет қаралды 73 М.
Using PowerShell to work with SharePoint Lists
19:09
Shane Young
Рет қаралды 29 М.
Intro to PowerShell for SharePoint
27:23
Shane Young
Рет қаралды 66 М.
How to use Write-Host for PowerShell
16:21
Shane Young
Рет қаралды 38 М.
PowerShell Arrays Introduction
19:20
Shane Young
Рет қаралды 54 М.
PowerShell predictors - PnP PowerShell and CLI for Microsoft 365
17:04
Microsoft Community Learning
Рет қаралды 597
Use the PowerShell Switch statement to replace Ifs
19:28
Shane Young
Рет қаралды 16 М.
This is How I Scrape 99% of Sites
18:27
John Watson Rooney
Рет қаралды 129 М.
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 122 МЛН