Pre-provision OneDrive For Business for all users

New Contributor

Hi all,


Quick question!
I simply want to run through roughly 2000 accounts in order to pre-provision OneDrive for all users, and I am using the code snippet taken from here:

(See Script below)


The question is simply. If I want to go through all users at once, will it then be as simply as to change '199' to '2000'? Or might there be a specific reason why the limit is set very specifically to '199'?


$Credential = Get-Credential
Connect-MsolService -Credential $Credential
Connect-SPOService -Credential $Credential -Url

$list = @()
$i = 0

#Get licensed users
$users = Get-MsolUser -All | Where-Object { $_.islicensed -eq $true }
#total licensed users
$count = $users.count

foreach ($u in $users) {
Write-Host "$i/$count"

$upn = $u.userprincipalname
$list += $upn

if ($i -eq 199) {
#We reached the limit
Request-SPOPersonalSite -UserEmails $list -NoWait
Start-Sleep -Milliseconds 655
$list = @()
$i = 0

if ($i -gt 0) {
Request-SPOPersonalSite -UserEmails $list -NoWait

0 Replies