Office 365: How to remove a ODFB site using PowerShell!

A common question in regards of OneDrive For Business (ODFB) is about how to delete a ODFB site in Office 365. Fortunately, this question has a simple answer: just use PowerShell. Indeed, using Remove-SPOSite you can easily delete an existing ODFB site as described in the following PowrShell script:

#Ejecución en la Consola de Administración de SharePoint Online

$sUserName="jcgonzalez@nuberosnet.onmicrosoft.com"

$sMessage="Introduce your SPO Credentials"

$sSPOAdminCenterUrl="https://nuberosnet-admin.sharepoint.com/" 

$msolcred = Get-Credential -UserName $sUserName -Message $sMessage

Connect-SPOService -Url $sSPOAdminCenterUrl -Credential $msolcred 

$spoSiteODFBSiteToDelete="https://nuberosnet-my.sharepoint.com/personal/user2_nuberosnet_onmicrosoft_com/"

Remove-SPOSite -Identity $spoSiteODFBSiteToDelete

If you run this PowerShell script in the SharePoint Online (SPO) Administration Console, you will see how the script is executed without problems:

image

Using Get-SPOSite you can verify that the ODFB site is not existing anymore:

image

Finally, if end user try to access his/her ODFB site, he will see that the ODFB site is going to be provisioned from scratch.

image

Office 365: ¿Se puede borrar el sitio de ODFB con PowerShell? (I)

Pues la respuesta es qué sí y para ello basta con utilizar el comando PowerShell Remove-SPOSite disponible para SharePoint Online:

#Ejecución en la Consola de Administración de SharePoint Online

$sUserName="jcgonzalez@nuberosnet.onmicrosoft.com"

$sMessage="Introduce your SPO Credentials"

$sSPOAdminCenterUrl="https://nuberosnet-admin.sharepoint.com/" 

$msolcred = Get-Credential -UserName $sUserName -Message $sMessage

Connect-SPOService -Url $sSPOAdminCenterUrl -Credential $msolcred 

$spoSiteODFBSiteToDelete="https://nuberosnet-my.sharepoint.com/personal/user2_nuberosnet_onmicrosoft_com/"

Remove-SPOSite -Identity $spoSiteODFBSiteToDelete

Si ejecutáis la secuencia de comandos PowerShell anterior, veréis que se ejecutan sin problemas:

image

Y si mediante Get-SPOSite tratáis de acceder al sitio borrado, veréis como el mismo no está disponible:

image

Si el usuario accede a su ODFB a través del portal de Office 365 verá como el mismo se provisiona de nuevo:

image