OneDrive site not found for user: Demo@Am1.onmicrosoft.com

ネパリ サンデャ 460 Reputation points
2023-07-13T08:36:31.4+00:00

I am using following script to disable Onedrive external setting
It doenot show any error but
OneDrive site not found for user: Demo@Am1.onmicrosoft.com
I checked my tenant Onedrive setting for the user is turn on
Now i know to what is happening

# Read CSV file
$csvPath = "C:\Users\Downloads\yuan.csv"
$csvData = Import-Csv -Path $csvPath

# Loop through each entry in the CSV file
foreach ($entry in $csvData) {
    $AdminCenterURL = $entry.AdminCenterURL
    $OneDriveHostURL = $entry.OneDriveSiteURL
    $SharingSettings = $entry.SharingSettings
    $User = $entry.User

    # Connect to Admin Center
    Connect-SPOService -Url $AdminCenterURL

    # Get OneDrive URL for the specified user
    $OneDriveURL = Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '*-my.sharepoint.com/personal/$User*'" |
                   Select-Object -ExpandProperty Url

    if ($OneDriveURL) {
        # Set External Sharing settings for an OneDrive site
        Set-SPOSite -Identity $OneDriveURL -SharingCapability $SharingSettings

        # Output the result
        Write-Host "External sharing settings disabled for user: $User"
    }
    else {
        Write-Host "OneDrive site not found for user: $User"
    }
}

OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,271 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,749 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emi Zhang-MSFT 27,161 Reputation points Microsoft Vendor
    2023-07-14T08:00:04.9266667+00:00

    Hi,

    I suggest you post this issue to OneDrive for Developer forum:

    https://techcommunity.microsoft.com/t5/onedrive-developer/bd-p/OneDriveDeveloper

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.