Output from PowerShell to OneDrive?

Joilson Cerqueira Oliveira Júnior 6 Reputation points Microsoft Employee
2023-07-25T13:55:32.09+00:00

Hello Experts,

I have a question, when using PowerShell to run a few queries on my tenant I need to save the output file to OneDrive, I managed to do it but I need to create an app and handle Client Secrets here and there, so this option is out of question.

The perfect solution will be that at the end of the script, when I call the Export-Csv -Path $csvFile the script should prompt the browser window, to save the Out-File into OneDrive, the user will complete the authentication and he should be able to browse and select the exact folder where the file.csv will be saved.

I might be asking too much but can someone guide me in how I can achieve this (or at least as close as possible)

Microsoft 365 and Office OneDrive For business Windows
Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. dashanan13 930 Reputation points
    2023-07-26T20:50:40.6733333+00:00

    Hei @Joilson Cerqueira Oliveira Júnior ,

    Thank you for contacting Microsoft community.

    If you are trying to upload to "One Drive for business" with authentication (no open to all folder) then i encourage you to visit this discussion that has the code and explanation, here

    On other hand if you are trying to upload to a open Onedrive folder or a regular http share thrn there is already a discussion here

    Please mark this as 'answer' if it helped

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.