Jul 21 2023 12:16 AM
Get-SPOUserOneDriveLocation -UserPrincipalName "email address removed for privacy reasons" gives location what exactly i need. How can i get the same by using PNP command? Please help.
I'm running a powershell script via Runbooks to get multi geo onedrive report. Hence getting the user onedrive location is important for me. I'm using pnp commands via client id and secret within my runbook.
Jul 21 2023 03:45 AM
Hi @KrisSub2023,
To obtain the current OneDrive location of a user in a Multi-Geo tenant environment using PnP PowerShell, follow these steps:
- Install the PnP PowerShell module in your environment (if not already installed) with the following command:
Install-Module SharePointPnPPowerShellOnline -Force
- Connect to SharePoint Online using PnP PowerShell and your client ID and secret. Ensure that your application has the required permissions in Azure AD.
# Replace 'YourClientId', 'YourClientSecret', and 'https://your-tenant-admin.sharepoint.com' with your actual values
$clientId = "YourClientId"
$clientSecret = "YourClientSecret"
$tenantAdminUrl = "https://your-tenant-admin.sharepoint.com"
Connect-PnPOnline -Url $tenantAdminUrl -AppId $clientId -AppSecret $clientSecret
- Retrieve the OneDrive location for the specific user:
# Replace 'email address removed for privacy reasons' with the user's email address
$userPrincipalName = "email address removed for privacy reasons"
$onedriveLocation = Get-PnPTenantSite -User $userPrincipalName | Select -ExpandProperty OneDriveLocation
- The variable $onedriveLocation now contains the URL of the user's OneDrive location in the Multi-Geo tenant environment.
- Once you have obtained the necessary information, don't forget to disconnect from SharePoint Online using the following command:
Disconnect-PnPOnline
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
Jul 21 2023 07:20 AM
Jul 23 2023 05:50 PM
ChatGPT generated answer unfortunately, those can be abit hit and miss as it can invent variables that does't exist
You can just run this:
Connect-SPOService -Url https://yourtentant-admin.sharepoint.com
Get-SPOUserOneDriveLocation -UserPrincipalName "The UPN You want to checl"
Jul 25 2023 07:50 PM
Jul 26 2023 08:10 AM
Aug 01 2023 10:31 PM