15 49.0138 8.38624 1 0 4000 1 https://vladtalkstech.com 300 1
theme-sticky-logo-alt

Find a user’s OneDrive for Business site URL with PowerShell

1 Comment

While working on an offboarding script, one of the requirements was to send an e-mail to the manager with the OneDrive for Business URL of the user that was going to get disabled. There is quite some information on the internet on how to get this with CSOM, but not a lot in how to get it with PowerShell for IT Pros like me … we prefer PowerShell cmdlets to code! While this is not available in the default SharePoint Online Module ,we can use the PnP PowerShell cmdlets to do it!

The first thing you must do is to get your credential and use the Connect-PnPOnline cmdlet to connect to your SharePoint Online Admin Center!

$cred = Get-Credential 
Connect-PnPOnline -Url https://<tenant>-admin.sharepoint.com/ -Credentials $cred

You can then run the Get-PnPUserProfileProperty cmdlet to get the information about the user’s profile and select only the PersonalUrl which is the URL of that user’s OneDrive for Business!

$username = "<UserName>" $OneDriveUrl = Get-PnPUserProfileProperty -Account
$username | select PersonalUrl
Find a user’s OneDrive for Business site URL with PowerShell

That’s it! Once you know the right cmdlets to use, it’s that simple!

Leave a comment and don’t forget to like the Vlad Talks Tech Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
Previous Post
Meet the Speaker series: Liam Cleary
Next Post
Meet the Speaker series: Daniel Christian

1 Comment

  • June 4, 2019 at 7:38 pm
    Deb Codding

    Very slick. Thanks so much. You saved me a lot of time!

    Reply

Leave a Reply