Hi SharePoint Online administrators!
This time I will show you how to:
Verify if a provisioned OneDrive for Business site was provisioned.
Is this really right…? What did they…(Åminne bruk, Värnamo, Sweden)
If you followed my previous post, Office 365 guide series – Provision OneDrive for Business using PowerShell then you will mst likely have a bunch of sites that you Think you have provisioned and are not really sure if it worked?
There are obviously ways to verify manuelly but if the list of users was long, then that is not the funniest work out there…
I suggest you use this script instead…:-)
If you have a single emaildomains in your oranization use the first one, if you have multiple emaildomains, use the second.
All you have to do is copy or retype the script to a Prompt/ps1 or ISE session, then run the script. You have the option to save some time by entering your account name in the script(see start)
1. Script 1 | Use this script if your organization only uses one domainname as email domain. For example, if you use only ‘contoso.com’ then you should use this script. |
2. Script 2 | Use this script if your organization only uses multiple domainnames as email domains. For example, if you use ‘contoso.com’, ‘microsoft.com’, northwindtraders.com’ as UPN names within your O365 tenant, then use this script. You will here be asked for the domain used in the O365 tenant address. |
3. Example 1 | Example of a usecase with multiple emaildomains and script 2. |
4. Example 2 | Example of a usecase with a single emaildomain and script 1. |
Note: If you copy paste the code from here into a PowerShell promt or ISE, please verify that all quotes and doublequotes are copied correctly, character coding may cause problems. |
‘
Single email domain in your oranization:
***** SCRIPT 1 STARTS HERE *****
# # By Thomas Balkeståhl - http://blog.blksthl.com # $o365cred = Get-Credential -Username "thomas.balkestahl@cramo.onmicrosoft.com" -Message "Supply a Office365 Admin" $Userlist = read-host "submit your list of users that have been provisioned" $Userlist = $Userlist -replace " ", "" $Emails = $userlist -split "," #Splitting list into Array Foreach($Email in $Emails) { # Constructing URL from the UPN/Email address $struser = $Email $pos= $strUser.IndexOf("@") $len = $struser.Length -1 $strUser = $strUser.SubString(0, $pos) $strUser = $strUser -replace "\.", "_" $orgpos = $pos + 1 $orglen = $len - $pos $strOrg = $Email.SubString($orgpos, $orglen) $strOrgNamePos = $strOrg.IndexOf(".") $strOrgName = $strOrg.SubString(0, $strOrgNamePos) $strOrgSuffixPos = $strOrgNamePos +1 $strOrgNameLen = $strOrg.Length - $strOrgSuffixPos $strOrgSuffix = $strOrg.SubString($strOrgSuffixPos, $strOrgNameLen) $strOrg = $strOrg -replace "\.", "_" $PersonalOrgURL = "https://" + $strOrgName + "-my.sharepoint.com/personal/" $SiteUrl= $PersonalOrgURL + $strUser $SiteUrl= $SiteUrl+ "_" + $strOrg write-host "Verifying user:" $Email $HTTP_Request = [System.Net.WebRequest]::Create($SiteUrl) $HTTP_Request.UseDefaultCredentials = $true $HTTP_Request.Credentials = $o365cred try { $HTTP_Response = $HTTP_Request.GetResponse() } catch [System.Net.WebException] { $HTTP_Response = $_.Exception.Response } $HTTP_Status = $HTTP_Response.StatusCode If ($HTTP_Status -eq 200 -or $HTTP_Status -eq 403 ) { Write-Host -ForegroundColor Green "Site for user $Email exists!" } Else { Write-Host -ForegroundColor Yellow "The OneDrive site for user $Email does not respond, try again later or provision it again" } $HTTP_Request = $null $HTTP_Response = $null $HTTP_Status = $Null }
***** SCRIPT 1 ENDS HERE *****
‘
‘
If you have multiple email domain in your oranization, use this second script:
***** SCRIPT 2 STARTS HERE *****
# # By Thomas Balkeståhl - http://blog.blksthl.com # $O365Admin = read-host "Supply your Office 365 Admin username(UPN)" # Add you admin account below, uncomment and comment out the line above to save time... # $O365Admin = "admin.user@domain.com" $o365cred = Get-Credential -Username $O365Admin -Message "Supply a Office365 Admin" $strO365OrgName = read-host "submit your O365 orgname (Only organization, like 'contoso')" $Userlist = read-host "submit your list of users that have been provisioned" $Userlist = $Userlist -replace " ", "" $Emails = $userlist -split "," #SPlitting list into Array Foreach($Email in $Emails) { # Constructing URL from the UPN/Email address $struser = $Email $pos= $strUser.IndexOf("@") $len = $struser.Length -1 $strUser = $strUser.SubString(0, $pos) $strUser = $strUser -replace "\.", "_" $orgpos = $pos + 1 $orglen = $len - $pos $strOrg = $Email.SubString($orgpos, $orglen) $strOrgNamePos = $strOrg.IndexOf(".") $strOrgName = $strOrg.SubString(0, $strOrgNamePos) $strOrgSuffixPos = $strOrgNamePos +1 $strOrgNameLen = $strOrg.Length - $strOrgSuffixPos $strOrgSuffix = $strOrg.SubString($strOrgSuffixPos, $strOrgNameLen) $strOrg = $strOrg -replace "\.", "_" $PersonalOrgURL = "https://" + $strO365OrgName + "-my.sharepoint.com/personal/" $SiteUrl= $PersonalOrgURL + $strUser $SiteUrl= $SiteUrl+ "_" + $strOrg write-host "Verifying user:" $Email $HTTP_Request = [System.Net.WebRequest]::Create($SiteUrl) $HTTP_Request.UseDefaultCredentials = $true $HTTP_Request.Credentials = $o365cred try { $HTTP_Response = $HTTP_Request.GetResponse() } catch [System.Net.WebException] { $HTTP_Response = $_.Exception.Response } $HTTP_Status = $HTTP_Response.StatusCode If ($HTTP_Status -eq 200 -or $HTTP_Status -eq 403 ) { Write-Host -ForegroundColor Green "Site for user $Email exists!" } Else { Write-Host -ForegroundColor Yellow "The OneDrive site for user $Email does not respond, try again later or provision it again" } $HTTP_Request = $null $HTTP_Response = $null $HTTP_Status = $Null }
***** SCRIPT 2 ENDS HERE *****
‘
‘
Example 1
‘
Multiple emaildomains
O365 Orgname: contoso
Users: test.user1@contoso.com, test.user2@northwind.com, test.user3@contoso.com, test.user4@contoso.com, test.user5@contoso.com
Like you can see, the list contains users with different emaildomains, contoso and northwind. THe submitted O365 orgname is however used to verify the OneDrive site, contoso.
In this example, the user test.user@contoso.com does not seem to have the OneDrive site provisioned.
‘
‘
Example 2
‘
Single emaildomain
Users: test.user1@contoso.com, test.user2@contoso.com, test.user3@contoso.com, test.user4@contoso.com, test.user5@contoso.com
Like you can see, the list contains users with only contoso as emaildomain.
In this example, the user test.user2@contoso.com does not seem to have the OneDrive site provisioned. Try to provision again/verify manuelly.
‘
‘
References and Credits
Office 365 guide series – Provision OneDrive for Business using PowerShell
http://blog.blksthl.com/2014/08/07/office-365-guide-series-provision-onedrive-for-business-using-powershell/
Credits & many thanks to
‘
Jörgen Andersson, Xperta
Always, Mattias Gutke at CAG
_________________________________________________________
Enjoy!
Regards
Twitter | Technet Profile | LinkedIn
