1. Open PowerShell in administrative mode.
2. Run "Install-Module -Name Microsoft.Online.SharePoint.PowerShell" command in powerShell.
3. Connect to SharePoint Services via command "Connect-SPOService -Url https://tenantname-admin.sharepoint.com"
Note: TenantName needs to be replaces with your organization tenant name.
4. To find your org tenant name, login to SharePoint admin center and check it's url. You will find your tenant name there.
5. For this article, I have my tenant name "m365x026100". Replace the tenant name with the actual name in step 2.
6. Modified SPO connect command will be "Connect-SPOService -Url https://m365x026100-admin.sharepoint.com"
7. Run the command in PowerShell.
8. Provide your office 365 admin credentials.
9. Once connected to SPO site, run the below command to block the OneDrive access of a user.
Get-SPOSite -Identity https://m365x026100-my.sharepoint.com/personal/username_userdomain_userdomainprefix | Set- SPOSite - LockState NoAccess ( It is only the format )
10. Modify the above command to block the specific user's OneDrive access in the mentioned manner.
Get-SPOSite -Identity https://m365x026100-my.sharepoint.com/personal/neha_cloudtechonline_xyz | Set-SPOSite - LockState NoAccess
11. For other user's also, we need to just change the above highlighted text with another user's name and domain.
12. Once command run, user's access to OneDrive will be blocked.
Note: To unlock the user's OneDrive access again, run the below command.
Get-SPOSite -Identity https://m365x026100-my.sharepoint.com/personal/neha_cloudtechonline_xyz | Set-SPOSite -LockState Unlock