I'm new to PowerShell and need to automate a OneDrive workflow. The script should search a root folder for PDF files, create anonymous read-only share links for them, organize the links by folder or tier, and build a register of the results. It should then associate PNG files with those links and create a separate PNG register. I've already configured permissions to allow reading, writing, and folder creation, but I'm struggling to get the script working and keep running into issues with OneDrive and Windows. Do I need to approach the workflow differently?
3 Answers
Running PowerShell as administrator probably isn’t relevant here. Elevation mainly affects permissions on the local computer, while creating OneDrive or cloud sharing links depends on the account, service, and API permissions being used. Make sure the script is authenticating to the correct OneDrive or Microsoft Graph service and has the required sharing permissions.
Start by learning the basics and posting the code you have so far, including the exact error messages. Nobody can reliably diagnose a script from a description alone. Test commands such as file filtering, folder creation, and CSV output independently before combining them into one workflow.
This is a fairly large automation project, especially for someone with only a few days of PowerShell experience. It would be easier to build and test it in small stages: first enumerate only the PDF files, then create one sharing link, then write that result to a CSV register, and only after that add folder organization and PNG handling. Copying a complete script without understanding each step will make troubleshooting difficult.

That makes sense. I’ve been relying heavily on generated code, but it keeps running into problems with OneDrive and Windows. I’ll break the workflow into smaller pieces and test each one.