Skip to content
EuroGamersOnline

EuroGamersOnline

Dominate the Consoles With our Console Guides

Primary Menu
  • Home
  • Console Gaming
  • PC Gaming
  • Gadgets
  • Contact Us
  • Home
  • Latest
  • How to upload files to SharePoint with MS Graph API and PowerShell

How to upload files to SharePoint with MS Graph API and PowerShell

2101

Microsoft Graph API and PowerShell provide a way to upload files to SharePoint using Office 365, providing an alternative means of uploading large amounts of data while still utilizing the power of online file storage.

The “upload file to sharepoint using graph api c#” is a tutorial that will show you how to upload files to SharePoint with the MS Graph API and PowerShell.

Using PowerShell to upload files to OneDrive or SharePoint using the Microsoft Graph API

I’ll show you how to upload files to SharePoint sites, including child folders, in the lesson below.

There is no way to accomplish this directly using the Microsoft Graph API URLs in the lesson. For your convenience, I’ve included a cmdlet in a module.

Achieve you want to know how you can do this without a module? Then go to the final paragraph and look at the official Microsoft Graph API documentation links.

Let’s go to work on Optimized. In PowerShell, mga

Using the Microsoft Graph API to get the Authorization token

Powershell is now open!

You may use the following cmdlet to install the module and submodule:

-Scope CurrentUser Install-Module Optimized.Mga.SharePoint

Copy the cmdlet below. Fill in the right values for ApplicationID, ClientSecret, and Tenant.

By invoking the cmdlet, you will generate an Authorization token that will be used by other cmdlets (such as Get-Mga) in the backend.

-ClientSecret ‘XXXX’ -ApplicationID ‘b5954443-ad10-4d1c-8cbc-dc05268a1858’ -Tenant ‘bwit.onmicrosoft.com’ $null = Connect-Mga -ClientSecret ‘XXXX’ -ApplicationID ‘b5954443-ad10-4d1c-8c

You should have gotten a notification saying that you are logged in if everything went fine.


We simply need one cmdlet this time: To upload files, use Upload-MgaSharePointFiles.

Upload files to SharePoint sites and OneDrives using Upload-MgaSharePointFiles. The cmdlet is included as part of the module. It takes the following value as a parameter:

  • TenantName
  • Site
  • ItemPath / Item
  • ChildFolders

TenantName and Site are self-explanatory. The TenantName is the address ‘*.onmicrosoft.com’. The Site field specifies the URL of the site to which you wish to upload a file.

The Item or ItemPath argument differs somewhat. The path string to the item you wish to upload to SharePoint is sent to ItemPath.

You may pick ‘Copy as path’ when you Shift + Right click a file, as seen in the image below. “C:tempblatemp.txt” will be the path for the copy.

How to upload files to SharePoint with MS Graph API and PowerShell How to use the MS Graph API and PowerShell to upload files to SharePoint

-ItemPath “C:tempblatemp.txt” -TenantName “m365x794103.onmicrosoft.com” -Site “XXXX” Upload-MgaSharePointFiles -ItemPath “C:tempblatemp.txt” -TenantName “m365x794103.onmicrosoft.com”

The argument Item takes an item from the [System.IO.FileSystemInfo] object. That is, before you start Upload-MgaSharePointFiles, you must first run Get-Item -Path C:tempblatemp.txt.

-Item Upload-MgaSharePointFiles (Get-Item “C:tempblatemp.txt”) -Site ‘XXXX’ -TenantName’m365x794103.onmicrosoft.com’ createdBy: @application=; user=; createdBy: @application=; user=; createdBy: @application=; user=; Date: 2021-12-15T17:03:27ZZZZZZZZZZZZZZZZZZZZZZZ id: 01MIYRG5I55BYRTHLDVZEJQTJWXXQDVKWP eTag: “1971E81D-639D-48AE-984D-36BDE03AAACF,7” eTag: “1971E81D-639D-48AE-984D-36BDE03AAACF,7” eTag: “1971E81D-639D-48AE-984D-36BDE03A lastModifiedBy: @application=; lastModifiedBy: @application=; lastModifiedBy: @application=; lastModifiedBy: @application=; last Date: 2021-12-15T18:27:32ZZZZZZZZZZZZZZZZZZZZZZZ blatemp.txt is a text file with the name blatemp.txt.

It all depends on how Upload-MgaSharePointFiles will be used. Do you wish to upload things in bulk? I’d recommend starting with Get-Item / Get-ChildItem and then using a foreach loop.

Get-ChildItem -Path’C:temp’foreach ($item in $Items) $Items = Get-ChildItem -Path’C:temp’foreach ($item in $Items) $Items = Get-ChildItem – -Item Upload-MgaSharePointFiles $item -Site ‘XXXX’ -TenantName ‘XXXX’

There is a non-mandatory parameter called ChildFolders. If you don’t provide ChildFolders, the root is utilized instead.

An array of subfolders may be sent to the ChildFolder option. You may use the following command to upload a file to a subfolder:

-Item Upload-MgaSharePointFiles (Get-Item “C:tempblatemp.txt”) -ChildFolders ‘XXXX’,’Personnel files’,’bas.wijdenes’,’Personal’ -TenantName ‘XXXX’,’Personal’,’Personal’,’Personal’,’Personal’,’Personal’,’Personal’,’Personal’,’Personal’,’Personal’,’Personal’ @application=; user=; createdBy: @application=; user=; createdBy: @application=; user=; createdB Date: 2021-12-15T17:03:27ZZZZZZZZZZZZZZZZZZZZZZZZZZZ “1971E81D-639D-48AE-984D-36BDE03AAACF,7” is an eTag. 01MIYRG5I55BYRTHLDVZEJQTJWXXQDVKWP id: 01MIYRG5I55BYRTHLDVZEJQTJWXXQDVKWP id: 01MIYRG5I55 @application=; user=; lastModifiedBy: 2021-12-15T18:27:32Z lastModifiedDateTime blatemp.txt is a text file with the name blatemp.txt.

As seen in the picture below, ChildFolders are folders in the root.

How to upload files to SharePoint with MS Graph API and PowerShellHow to use the MS Graph API and PowerShell to upload files to SharePoint


The Microsoft Graph API documentation

This lesson makes use of the Microsoft Graph API documentation:

Get a SharePoint site: Microsoft Graph beta | Microsoft Docs | Get a SharePoint site

Microsoft Docs | Resumable file upload: Resumable file upload – Microsoft Graph v1.0

Related

The “powershell post file to api” is a PowerShell command that can be used to upload files to SharePoint using the MS Graph API.

Related Tags

  • upload folder to sharepoint online powershell ms graph
  • upload file in powershell
  • powershell upload file to box
  • invoke-webrequest upload binary file
  • box com powershell

Continue Reading

Previous: Best 8 Ways To Download Reels From Instagram For Free
Next: How to Delete Badoo Account Permanently? [Updated December 2021]

Trending Now

Level Up Your Online Gaming Sessions: How HHC Promotes Relaxed Focus Image2 1

Level Up Your Online Gaming Sessions: How HHC Promotes Relaxed Focus

The Evolution of Lottery in Sabatoto and Togel279: From Turf Club to Trusted Online Platforms Image2 2

The Evolution of Lottery in Sabatoto and Togel279: From Turf Club to Trusted Online Platforms

How Togel158 and Colok178 Changed the Landscape of Lottery Gambling Legally Image1 3

How Togel158 and Colok178 Changed the Landscape of Lottery Gambling Legally

Why Payout Speeds Are Important at Online Casinos? Image3 4

Why Payout Speeds Are Important at Online Casinos?

Your Guide to Fair and Transparent CS2 Case Opening Image2 5

Your Guide to Fair and Transparent CS2 Case Opening

How to Avoid Mistakes in PDFs: The Mistake PDF the mistake pdf 6

How to Avoid Mistakes in PDFs: The Mistake PDF

Related Stories

Getting The Most Out Of Slot Machines Without Getting Played

Getting The Most Out Of Slot Machines Without Getting Played

17
Innovations in Betting Platforms: Artificial Intelligence and Mobile AppsĀ 

Innovations in Betting Platforms: Artificial Intelligence and Mobile AppsĀ 

18
How Gamified Learning Platforms Like Blooket Compare to Slots

How Gamified Learning Platforms Like Blooket Compare to Slots

47
Ultimate10 Popular Mods for DayZ in 2025 Image9

Ultimate10 Popular Mods for DayZ in 2025

71
The Rise of Togel178 and Pedetogel: A Journey Through Time Image1

The Rise of Togel178 and Pedetogel: A Journey Through Time

84
Speed Meets Strategy: Five Mobile Apps That Turn Spare Minutes Into Game Time Image2

Speed Meets Strategy: Five Mobile Apps That Turn Spare Minutes Into Game Time

95

Trending News

The bottom line on NBCUniversal’s possible movie-saving plan sources comcast nbcuniversal hbo netflix peacockshawbloomberg 1

The bottom line on NBCUniversal’s possible movie-saving plan

What the Mindbody-ClassPass deal means for the fitness industry mindbody classpass 500m sixth streetcrooktechcrunch 2

What the Mindbody-ClassPass deal means for the fitness industry

What this Means for Google Users in the EU the european e2eevincent theverge 3

What this Means for Google Users in the EU

How Amazon Kindle Makes it Easier to Load eBooks you Didn’t Buy From Amazon 4

How Amazon Kindle Makes it Easier to Load eBooks you Didn’t Buy From Amazon

How Citibank Learned its Lesson 5

How Citibank Learned its Lesson

Why EA is Sought After by Amazon, Disney, and Apple 6

Why EA is Sought After by Amazon, Disney, and Apple

The Rise of Tech Start-Ups in South-East Asia 7

The Rise of Tech Start-Ups in South-East Asia

Address: 8321 Polmolas Street, Meles, CO 63724

  • Meet The Crew
  • Contact Us
  • Privacy Policy
  • T&C
Copyright @ 2023 All rights reserved to EuroGamerOnline