From c461b9618981b77742da052516ef29b2ac9e3c9c Mon Sep 17 00:00:00 2001 From: brhoyle <102037846+brhoyle@users.noreply.github.com> Date: Mon, 20 Jan 2025 15:51:23 -0500 Subject: [PATCH] Update pre-provision-accounts.md Script was no longer working due to changes in MgGraph command. Changed Connect method to the MFA method instead of user name and password. Since Get-MGUser no longer has a property called "IsLicensed" I replaced "$users = Get-MgUser -All | Where-Object { $_.islicensed -eq $true }" with "$users = Get-MgUser -Filter 'assignedLicenses/$count ne 0' -ConsistencyLevel eventual -CountVariable unlicensedUserCount -All;" Chanchal Jain "chja" provided new correct command. --- SharePoint/SharePointOnline/pre-provision-accounts.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SharePoint/SharePointOnline/pre-provision-accounts.md b/SharePoint/SharePointOnline/pre-provision-accounts.md index 2d40389cb8..278421b24e 100644 --- a/SharePoint/SharePointOnline/pre-provision-accounts.md +++ b/SharePoint/SharePointOnline/pre-provision-accounts.md @@ -89,12 +89,13 @@ To verify that OneDrive has been created for your users, see [Get a list of all ## Pre-provision OneDrive for all licensed users in your organization -The following code snippet will pre-provision OneDrive in batches of 199. +The following code snippet will pre-provision all licensed users OneDrive in batches of 199. + ```PowerShell -$Credential = Get-Credential -Connect-MgGraph -Credential $Credential -Connect-SPOService -Credential $Credential -Url https://contoso-admin.sharepoint.com +## Connecting to Graph and SharePoint using the MFA connection method. +Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" +Connect-SPOService -Url https://contoso-admin.sharepoint.com/ $list = @() #Counters @@ -102,7 +103,7 @@ $i = 0 $j = 0 #Get licensed users -$users = Get-MgUser -All | Where-Object { $_.islicensed -eq $true } +$users = Get-MgUser -Filter 'assignedLicenses/$count ne 0' -ConsistencyLevel eventual -CountVariable unlicensedUserCount -All; #total licensed users $count = $users.count