Here is the
script to get a list with user and their OneDrive Url information.
·
Install
PnP module first:
Install-Module PnP.PowerShell
Replace the
account and tenant information in the following script and run the following
command:
$creds = (New - Object
System.Management.Automation.PSCredential "XXX@XXX.onmicrosoft.com",
(ConvertTo - SecureString "PASSWORD" - AsPlainText - Force)) Connect - PnPOnline - Url “https: //XXX.sharepoint.com”
-Credentials $creds $userList = get - PnpUser $results = New - Object
System.Collections.ArrayList foreach($user in $userList) { if
([string]::IsNullOrWhiteSpace($user.Email)) {
continue } $userInfo = Get -
PnPUserProfileProperty - Account $user.Email $item = New - Object
System.Object $item | Add - Member -
MemberType NoteProperty - Name "Email" - Value $user.Email $item | Add - Member -
MemberType NoteProperty - Name "OneDriveUrl" - Value
$userInfo.PersonalUrl $results.Add($item) | Out
- Null } #Output result $results | Export-CSV 'C:\Users\XXX\XXX\Desktop\Url
Details.csv' -Force |
No comments:
Post a Comment