Hi,
Just wanted to share this one to make it easier for others.
Check currently activated Onedrive sites from a tenant:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# Specifies the URL for your organization's SPO admin service $AdminURI = "https://your organization name-admin.sharepoint.com" # Specifies the User account for an Office 365 global admin in your organization $AdminAccount = "global admin account" $AdminPass = "password for global admin account" # Specifies the location where the list of URLs should be saved $LogFile = 'C:\Users\youralias\Desktop\ListOfMysites.txt' # Begin the process $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $loadInfo3 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles") # Convert the Password to a secure string, then zero out the cleartext version ;) $sstr = ConvertTo-SecureString -string $AdminPass -AsPlainText –Force $AdminPass = "" # Take the AdminAccount and the AdminAccount password, and create a credential $creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($AdminAccount, $sstr) # Add the path of the User Profile Service to the SPO admin URL, then create a new webservice proxy to access it $proxyaddr = "$AdminURI/_vti_bin/UserProfileService.asmx?wsdl" $UserProfileService= New-WebServiceProxy -Uri $proxyaddr -UseDefaultCredential False $UserProfileService.Credentials = $creds # Set variables for authentication cookies $strAuthCookie = $creds.GetAuthenticationCookie($AdminURI) $uri = New-Object System.Uri($AdminURI) $container = New-Object System.Net.CookieContainer $container.SetCookies($uri, $strAuthCookie) $UserProfileService.CookieContainer = $container # Sets the first User profile, at index -1 $UserProfileResult = $UserProfileService.GetUserProfileByIndex(-1) Write-Host "Starting- This could take a while." $NumProfiles = $UserProfileService.GetUserProfileCount() $i = 1 # As long as the next User profile is NOT the one we started with (at -1)... While ($UserProfileResult.NextValue -ne -1) { Write-Host "Examining profile $i of $NumProfiles" # Look for the Personal Space object in the User Profile and retrieve it # (PersonalSpace is the name of the path to a user's OneDrive for Business site. Users who have not yet created a # OneDrive for Business site might not have this property set.) $Prop = $UserProfileResult.UserProfile | Where-Object { $_.Name -eq "PersonalSpace" } $Url= $Prop.Values[0].Value # If "PersonalSpace" (which we've copied to $Url) exists, log it to our file... if ($Url) { $Url | Out-File $LogFile -Append -Force } # And now we check the next profile the same way... $UserProfileResult = $UserProfileService.GetUserProfileByIndex($UserProfileResult.NextValue) $i++ } Write-Host "Done!" |
And Bulk provision users based on a text file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<# .SYNOPSIS This script adds an entry for each user specified in the input file into the OneDrive provisioning queue .DESCRIPTION This script reads a text file with a line for each user. Provide the User Principal Name of each user on a new line. An entry will be made in the OneDrive provisioning queue for each user up to 200 users. .EXAMPLE .\BulkEnqueueOneDriveSite.ps1 -SPOAdminUrl https://contoso-admin.sharepoint.com -InputfilePath C:\users.txt .PARAMETER SPOAdminUrl The URL for the SharePoint Admin center https://contoso-admin.sharepoint.com .PARAMETER InputFilePath The path to the input file. The file must contain 1 to 200 users C:\users.txt .NOTES This script needs to be run by a SharePoint Online Tenant Administrator This script will prompt for the username and password of the Tenant Administrator #> param ( #Must be SharePoint Administrator URL [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $SPOAdminUrl, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $InputFilePath ) [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles") | Out-Null $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SPOAdminUrl) $Users = Get-Content -Path $InputFilePath if ($Users.Count -eq 0 -or $Users.Count -gt 200) { Write-Host $("Unexpected user count: [{0}]" -f $Users.Count) -ForegroundColor Red return } $web = $ctx.Web Write-Host "Please enter a Tenant Admin username" -ForegroundColor Green $username = Read-Host Write-Host "Please enter your password" -ForegroundColor Green $password = Read-Host -AsSecureString $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$password ) $ctx.Load($web) $ctx.ExecuteQuery() $loader = [Microsoft.SharePoint.Client.UserProfiles.ProfileLoader]::GetProfileLoader($ctx) $ctx.ExecuteQuery() $loader.CreatePersonalSiteEnqueueBulk($Users) $loader.Context.ExecuteQuery() Write-Host "Script Completed" |
Links for instructions.