locked
Remove a Tenant from a multitenant Sharepoint profile service

    Question

  • Hi guys,

    I'm workin on a sharepoint 2010 multitenant installation. On this farm I created a "tenant" using powershell (New-SPSiteSubscription, create site, create admin site and so on...) and I created a corresponding profile service using

    Add-SPSiteSubscriptionProfileConfig -id $sub -MySiteHostLocation "$urlMKTG/mysite" -MySiteManagedPath "mysite/personal" -SynchronizationOU $ouMKTG -ProfileServiceApplicationProxy (Get-SPServiceApplicationProxy |?{$_.TypeName -eq "User Profile Service Application Proxy"})

    well everything was ok.

    Now I removed the subscription via "remove-SpSiteSubscripion" and I had no errors, but when I try to re-create the tenant above, on "Add-SPSiteSubscriptionProfileConfig" receive the followinf message:

    Add-SPSiteSubscriptionProfileConfig : The synchronization OU specified in the SynchronizationOU parameter is already assigned to a differen
    t site subscription in the proxy specified by the ProfileServiceApplicationProxy parameter.
    At ...\10.3 - Tenant Provisioning (hostheader).ps1:55 char:36

    + Add-SPSiteSubscriptionProfileConfig <<<<  -id $sub -MySiteHostLocation "$urlMKTG/mysite" -MySiteManagedPath "mysite/personal" -SynchronizationOU $ouMKTG -ProfileServiceApplicationProxy (Get-SPServiceApplicationProxy |?{$_.TypeName -eq "User Profile Service Application Proxy"}
    )
        + CategoryInfo          : InvalidArgument: (Microsoft.Offic...ddProfileTenant:SPCmdletAddProfileTenant) [Add-SPSiteSubscriptionProfile   Config], InvalidOperationException
        + FullyQualifiedErrorId : Microsoft.Office.Server.UserProfiles.PowerShell.SPCmdletAddProfileTenant

    Infact, if I go to Central Admin to "manage profile service" I can see that I have "Number of Tenants: 1".

    The question Is: because I removed the subscription, I want to remove the tenant from the profile service too. How can I do it?

    thanks!


    Nicola
    Wednesday, May 26, 2010 4:54 PM

Answers

  • Hi,

    If you want to delete an existing tenant then you  User Power Shell by using following command

    // This will give you all subscription ID
    $sub = get-spsitesubscription 
    
    // This will remove the subscription ID received from the above command
    remove-spsitesubscription -identity "$sub"

    Now navigate to Sharepoint Database and Delete all the references of the PartitionID (subscription ID) from "ProfileDB" Table.

    The above job is a tedius task and will take some time to remove all the IDs from Sharepoint Tables.

    Next , Try the folowing ps script to create new Tenant and can use original ( previous) OU.

    Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0 
    
    # farm details - update to reflect environment
    $customerName = "<OU Name>"
    $customerTenantAdmin = "<OU Admin with domain>"	
    $ouName= "<OU Name>"
    $fullOUPath = 'OU=<OU PATH>,OU=<OU PATH>,DC=<Domain Name>,DC=<Domain Name>'
    $fullTenantURL = "http://<testsiteurl>"
    $customerFeatures = $customfeature
    $hostingMainURL = "http://<HostingWebApplicationURL>"
    $upaProxyName = "<User Profile Proxy> Farm Tenant User Profile Service Proxy"
    $mmsProxyName = "<User MetaData Proxy> Farm Tenant Managed Metadata Service Proxy"
    
    # feature packs - update after creating them
    $foundationFeatures = "479a3211-b2c8-4efd-b09e-a11194c8ef79"
    $standardFeatures = "400e72d3-7a97-4e28-8a9a-ac0f6ffba4e6"
    $enterpriseFeatures = "0da79437-5735-4550-b4b1-2f9608ecb328"
    $customfeature="0da79437-5735-4550-b4b1-2f9608ecb328"
    $a = Read-Host "Have you added the user running this script to *permissions* on the UPA?"
        $webApp = Get-SPWebApplication $hostingMainURL
        # create new Site Subscription
        Write-Host "Creating Site Subcription..."
        $sub = New-SPSiteSubscription
    
    
        # assign feature pack and configure the OU to use in the People Picker for the Subscription
        Write-Host "Assiging Feature Pack and configuring People Picker..."
        
        Set-SPSiteSubscriptionConfig –id $sub -FeaturePack $enterpriseFeatures -UserAccountDirectoryPath $fullOUPath
    
    
    function ProvisionTenant($enterpriseFeatures,$customerName, $customerTenantAdmin, $customerFeatures, $hostingMainURL, $upaProxyName, $mmsProxyName, $foundationFeatures, $ouName, $fullTenantURL, $fullOUPath, $webApp, $sub)
    {
        Write-Host "Provisioning Tenant..."
        Write-Host "Name: $customerName"
        Write-Host "Admin: $customerTenantAdmin"
    
    
    	
    	$a = Read-Host "Are Details ok ?"
     
        # grab the web app
    
    
        # create the "main" member site (we need a site at the root to use Host Headers and Managed Paths in the following cmdlets)
        Write-Host "Creating Root Site..."
        New-SPSite -url "$fullTenantURL" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template BLANKINTERNETCONTAINER#0
    
        # create Tenant Admin site 
        Write-Host "Creating Tenant Admin site..."
        New-SPSite -url "$fullTenantURL/admin" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template tenantadmin#0 -AdministrationSiteType TenantAdministration
    
        # everything else needs standard
        if (!($customerFeatures -eq $foundationFeatures))
        {
            Write-Host "Tenant has SharePoint Server features"
            # create a mysite host
            Write-Host "Creating My Site Host..."
            New-SPSite -url "$fullTenantURL/mysites" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template SPSMSITEHOST#0
    
            # configure the MySites host, MySites path, Naming Resolution and Profile Sync OU for the Subscription
            Write-Host "Configuring Tenant Profile Config..."
            $upaProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $upaProxyName}
    	$upaProxy
            ADD-SPSiteSubscriptionProfileConfig -id $sub -SynchronizationOU $ouName -MySiteHostLocation "$fullTenantURL/mysites" -MySiteManagedPath "/mysites/personal" -SiteNamingConflictResolution "None" -ProfileServiceApplicationProxy $upaProxy
    
            # create a site for the Content Type Gallery
            Write-Host "Creating Content Type Gallery..."
            New-SPSite -url "$fullTenantURL/cthub" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template sts#0
    
            # configure the Content Type Gallery for the Subscription
            Write-Host "Configuring Tenant Content Type Gallery..."
            $mmsProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $mmsProxyName}
    	$mmsProxy
            # ContentTypeHub feature activation may fail - if so activate manually
            Set-SPSiteSubscriptionMetadataConfig -identity $sub -serviceProxy $mmsProxy -huburi "$fullTenantURL/cthub" -SyndicationErrorReportEnabled
            Write-Host "Activating Content Type Hub..."
            Enable-SPFeature -Identity ContentTypeHub -url "$fullTenantURL/cthub"
            
            
        }
    
    
        #Set-SPSiteSubscriptionEdiscoveryHub - create an ediscovery hub, requires site - -SearchScope 1 - all of the sub
        
        Write-Host "Tenant Provisioned!"
        return $sub
    
    }
    
    
    #----------------------------------------------------
    #Customer Name will be used in the URL and The site names 
    
    
    
    ProvisionTenant $enterpriseFeatures $customerName $customerTenantAdmin $customerFeatures $hostingMainURL $upaProxyName $mmsProxyName $foundationFeatures $ouName $fullTenantURL $fullOUPath $webApp $sub
    
    

    Best Practice : Delete Site Collection associated with that Tenant ( Subscription ID ) rather than deleting directly the subscription ID from Remove-SPSieSubscriptin  command.

    Once all the associated  Site Collections are deleted then you can use the very same Subsciption ID which you were removing earlier from the PS Script and now you can use this Subscrition ID by set-spsite... command.

    Use the following steps :

    1.) Delete all site collections related to tenant by ui or ps command

    2.) Get Subscription ID , you will notice the subscription Id with blank entry of associated site Collections.

    3.) use following ps script:

    Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0 
    
    # farm details - update to reflect environment
    $customerName = "<OU Name>"
    $customerTenantAdmin = "<OU Admin with domain>"	
    $ouName= "<OU Name>"
    $fullOUPath = 'OU=<OU PATH>,OU=<OU PATH>,DC=<Domain Name>,DC=<Domain Name>'
    $fullTenantURL = "http://<testsiteurl>"
    $customerFeatures = $customfeature
    $hostingMainURL = "http://<HostingWebApplicationURL>"
    $upaProxyName = "<User Profile Proxy> Farm Tenant User Profile Service Proxy"
    $mmsProxyName = "<User MetaData Proxy> Farm Tenant Managed Metadata Service Proxy"
    
    # feature packs - update after creating them
    $foundationFeatures = "479a3211-b2c8-4efd-b09e-a11194c8ef79"
    $standardFeatures = "400e72d3-7a97-4e28-8a9a-ac0f6ffba4e6"
    $enterpriseFeatures = "0da79437-5735-4550-b4b1-2f9608ecb328"
    $customfeature="0da79437-5735-4550-b4b1-2f9608ecb328"
    $a = Read-Host "Have you added the user running this script to *permissions* on the UPA?"
        $webApp = Get-SPWebApplication $hostingMainURL
        # create new Site Subscription
        Write-Host "Creating Site Subcription..."
        //$sub = New-SPSiteSubscription
    $sub = "<use the existing old Subscription ID here>"
    
    
        # assign feature pack and configure the OU to use in the People Picker for the Subscription
        Write-Host "Assiging Feature Pack and configuring People Picker..."
        
        Set-SPSiteSubscriptionConfig –id $sub -FeaturePack $enterpriseFeatures -UserAccountDirectoryPath $fullOUPath
    
    
    function ProvisionTenant($enterpriseFeatures,$customerName, $customerTenantAdmin, $customerFeatures, $hostingMainURL, $upaProxyName, $mmsProxyName, $foundationFeatures, $ouName, $fullTenantURL, $fullOUPath, $webApp, $sub)
    {
        Write-Host "Provisioning Tenant..."
        Write-Host "Name: $customerName"
        Write-Host "Admin: $customerTenantAdmin"
    
    
    	
    	$a = Read-Host "Are Details ok ?"
     
        # grab the web app
    
    
        # create the "main" member site (we need a site at the root to use Host Headers and Managed Paths in the following cmdlets)
        Write-Host "Creating Root Site..."
        New-SPSite -url "$fullTenantURL" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template BLANKINTERNETCONTAINER#0
    
        # create Tenant Admin site 
        Write-Host "Creating Tenant Admin site..."
        New-SPSite -url "$fullTenantURL/admin" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template tenantadmin#0 -AdministrationSiteType TenantAdministration
    
        # everything else needs standard
        if (!($customerFeatures -eq $foundationFeatures))
        {
            Write-Host "Tenant has SharePoint Server features"
            # create a mysite host
            Write-Host "Creating My Site Host..."
            New-SPSite -url "$fullTenantURL/mysites" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template SPSMSITEHOST#0
    
            # configure the MySites host, MySites path, Naming Resolution and Profile Sync OU for the Subscription
            Write-Host "Configuring Tenant Profile Config..."
            $upaProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $upaProxyName}
    	$upaProxy
            SET-SPSiteSubscriptionProfileConfig -id $sub -SynchronizationOU $ouName -MySiteHostLocation "$fullTenantURL/mysites" -MySiteManagedPath "/mysites/personal" -SiteNamingConflictResolution "None" -ProfileServiceApplicationProxy $upaProxy
    
            # create a site for the Content Type Gallery
            Write-Host "Creating Content Type Gallery..."
            New-SPSite -url "$fullTenantURL/cthub" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template sts#0
    
            # configure the Content Type Gallery for the Subscription
            Write-Host "Configuring Tenant Content Type Gallery..."
            $mmsProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $mmsProxyName}
    	$mmsProxy
            # ContentTypeHub feature activation may fail - if so activate manually
            Set-SPSiteSubscriptionMetadataConfig -identity $sub -serviceProxy $mmsProxy -huburi "$fullTenantURL/cthub" -SyndicationErrorReportEnabled
            Write-Host "Activating Content Type Hub..."
            Enable-SPFeature -Identity ContentTypeHub -url "$fullTenantURL/cthub"
            
            
        }
    
    
        #Set-SPSiteSubscriptionEdiscoveryHub - create an ediscovery hub, requires site - -SearchScope 1 - all of the sub
        
        Write-Host "Tenant Provisioned!"
        return $sub
    
    }
    
    
    #----------------------------------------------------
    #Customer Name will be used in the URL and The site names 
    
    
    
    ProvisionTenant $enterpriseFeatures $customerName $customerTenantAdmin $customerFeatures $hostingMainURL $upaProxyName $mmsProxyName $foundationFeatures $ouName $fullTenantURL $fullOUPath $webApp $sub
    
    

    *** SET Subscription ID command will Work with SP1 of Sharepoint 2010 ***

    Let me know if the above explanation helps.

    Thanks

    Gyan


    Monday, April 09, 2012 9:34 PM

All replies

  • I'm getting the same error, anyone out there able to help?
    Sunday, May 30, 2010 1:49 PM
  • This should be a workaround:

    1. Go to your database server
    2. Navigate to the User Profile Server "ProfileDB"
    3. Open up the Tenants table (i.e. Select top 1000 rows or do a select all where SynchronizationOU = 'the-OU-in-question')
    4. Perform a query to change that SynchronizationOU to NULL or something else that's bogus
    Cheers,
    Greg

    Sunday, May 30, 2010 3:13 PM
  • I've tried this way, but it doesn't work for me. My workaround is:

    * delete old subscription

    * create new OU

    * re-create subscription with new OU for Profile Config

    Monday, June 27, 2011 4:53 PM
  • I am experiencing the same problem. Anyone figured this out yet?

    The work arounds posted here should work but is there anything from Microsoft regarding this? OR, a process to remove tenants properly?

     

    Brian

    Monday, January 09, 2012 3:11 PM
  • You could try

    Remove-SPSiteSubscriptionProfileConfig

    Richard

    Sunday, February 05, 2012 11:57 PM
  • Richard, nice to see you on the forums! :-)

    Unfortunately Remove-SPSiteSubscriptionProfileConfig won't work if the Site Subscription has already been deleted, which is what the OP has found.  The only unsupported way of fixing this is to manually modify the Profile database.  The only supported workaround is to re-create the multi-tenant UPA.


    http://sharepoint.nauplius.net
    Monday, February 06, 2012 12:46 AM
    Moderator
  • Hi,

    If you want to delete an existing tenant then you  User Power Shell by using following command

    // This will give you all subscription ID
    $sub = get-spsitesubscription 
    
    // This will remove the subscription ID received from the above command
    remove-spsitesubscription -identity "$sub"

    Now navigate to Sharepoint Database and Delete all the references of the PartitionID (subscription ID) from "ProfileDB" Table.

    The above job is a tedius task and will take some time to remove all the IDs from Sharepoint Tables.

    Next , Try the folowing ps script to create new Tenant and can use original ( previous) OU.

    Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0 
    
    # farm details - update to reflect environment
    $customerName = "<OU Name>"
    $customerTenantAdmin = "<OU Admin with domain>"	
    $ouName= "<OU Name>"
    $fullOUPath = 'OU=<OU PATH>,OU=<OU PATH>,DC=<Domain Name>,DC=<Domain Name>'
    $fullTenantURL = "http://<testsiteurl>"
    $customerFeatures = $customfeature
    $hostingMainURL = "http://<HostingWebApplicationURL>"
    $upaProxyName = "<User Profile Proxy> Farm Tenant User Profile Service Proxy"
    $mmsProxyName = "<User MetaData Proxy> Farm Tenant Managed Metadata Service Proxy"
    
    # feature packs - update after creating them
    $foundationFeatures = "479a3211-b2c8-4efd-b09e-a11194c8ef79"
    $standardFeatures = "400e72d3-7a97-4e28-8a9a-ac0f6ffba4e6"
    $enterpriseFeatures = "0da79437-5735-4550-b4b1-2f9608ecb328"
    $customfeature="0da79437-5735-4550-b4b1-2f9608ecb328"
    $a = Read-Host "Have you added the user running this script to *permissions* on the UPA?"
        $webApp = Get-SPWebApplication $hostingMainURL
        # create new Site Subscription
        Write-Host "Creating Site Subcription..."
        $sub = New-SPSiteSubscription
    
    
        # assign feature pack and configure the OU to use in the People Picker for the Subscription
        Write-Host "Assiging Feature Pack and configuring People Picker..."
        
        Set-SPSiteSubscriptionConfig –id $sub -FeaturePack $enterpriseFeatures -UserAccountDirectoryPath $fullOUPath
    
    
    function ProvisionTenant($enterpriseFeatures,$customerName, $customerTenantAdmin, $customerFeatures, $hostingMainURL, $upaProxyName, $mmsProxyName, $foundationFeatures, $ouName, $fullTenantURL, $fullOUPath, $webApp, $sub)
    {
        Write-Host "Provisioning Tenant..."
        Write-Host "Name: $customerName"
        Write-Host "Admin: $customerTenantAdmin"
    
    
    	
    	$a = Read-Host "Are Details ok ?"
     
        # grab the web app
    
    
        # create the "main" member site (we need a site at the root to use Host Headers and Managed Paths in the following cmdlets)
        Write-Host "Creating Root Site..."
        New-SPSite -url "$fullTenantURL" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template BLANKINTERNETCONTAINER#0
    
        # create Tenant Admin site 
        Write-Host "Creating Tenant Admin site..."
        New-SPSite -url "$fullTenantURL/admin" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template tenantadmin#0 -AdministrationSiteType TenantAdministration
    
        # everything else needs standard
        if (!($customerFeatures -eq $foundationFeatures))
        {
            Write-Host "Tenant has SharePoint Server features"
            # create a mysite host
            Write-Host "Creating My Site Host..."
            New-SPSite -url "$fullTenantURL/mysites" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template SPSMSITEHOST#0
    
            # configure the MySites host, MySites path, Naming Resolution and Profile Sync OU for the Subscription
            Write-Host "Configuring Tenant Profile Config..."
            $upaProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $upaProxyName}
    	$upaProxy
            ADD-SPSiteSubscriptionProfileConfig -id $sub -SynchronizationOU $ouName -MySiteHostLocation "$fullTenantURL/mysites" -MySiteManagedPath "/mysites/personal" -SiteNamingConflictResolution "None" -ProfileServiceApplicationProxy $upaProxy
    
            # create a site for the Content Type Gallery
            Write-Host "Creating Content Type Gallery..."
            New-SPSite -url "$fullTenantURL/cthub" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template sts#0
    
            # configure the Content Type Gallery for the Subscription
            Write-Host "Configuring Tenant Content Type Gallery..."
            $mmsProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $mmsProxyName}
    	$mmsProxy
            # ContentTypeHub feature activation may fail - if so activate manually
            Set-SPSiteSubscriptionMetadataConfig -identity $sub -serviceProxy $mmsProxy -huburi "$fullTenantURL/cthub" -SyndicationErrorReportEnabled
            Write-Host "Activating Content Type Hub..."
            Enable-SPFeature -Identity ContentTypeHub -url "$fullTenantURL/cthub"
            
            
        }
    
    
        #Set-SPSiteSubscriptionEdiscoveryHub - create an ediscovery hub, requires site - -SearchScope 1 - all of the sub
        
        Write-Host "Tenant Provisioned!"
        return $sub
    
    }
    
    
    #----------------------------------------------------
    #Customer Name will be used in the URL and The site names 
    
    
    
    ProvisionTenant $enterpriseFeatures $customerName $customerTenantAdmin $customerFeatures $hostingMainURL $upaProxyName $mmsProxyName $foundationFeatures $ouName $fullTenantURL $fullOUPath $webApp $sub
    
    

    Best Practice : Delete Site Collection associated with that Tenant ( Subscription ID ) rather than deleting directly the subscription ID from Remove-SPSieSubscriptin  command.

    Once all the associated  Site Collections are deleted then you can use the very same Subsciption ID which you were removing earlier from the PS Script and now you can use this Subscrition ID by set-spsite... command.

    Use the following steps :

    1.) Delete all site collections related to tenant by ui or ps command

    2.) Get Subscription ID , you will notice the subscription Id with blank entry of associated site Collections.

    3.) use following ps script:

    Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0 
    
    # farm details - update to reflect environment
    $customerName = "<OU Name>"
    $customerTenantAdmin = "<OU Admin with domain>"	
    $ouName= "<OU Name>"
    $fullOUPath = 'OU=<OU PATH>,OU=<OU PATH>,DC=<Domain Name>,DC=<Domain Name>'
    $fullTenantURL = "http://<testsiteurl>"
    $customerFeatures = $customfeature
    $hostingMainURL = "http://<HostingWebApplicationURL>"
    $upaProxyName = "<User Profile Proxy> Farm Tenant User Profile Service Proxy"
    $mmsProxyName = "<User MetaData Proxy> Farm Tenant Managed Metadata Service Proxy"
    
    # feature packs - update after creating them
    $foundationFeatures = "479a3211-b2c8-4efd-b09e-a11194c8ef79"
    $standardFeatures = "400e72d3-7a97-4e28-8a9a-ac0f6ffba4e6"
    $enterpriseFeatures = "0da79437-5735-4550-b4b1-2f9608ecb328"
    $customfeature="0da79437-5735-4550-b4b1-2f9608ecb328"
    $a = Read-Host "Have you added the user running this script to *permissions* on the UPA?"
        $webApp = Get-SPWebApplication $hostingMainURL
        # create new Site Subscription
        Write-Host "Creating Site Subcription..."
        //$sub = New-SPSiteSubscription
    $sub = "<use the existing old Subscription ID here>"
    
    
        # assign feature pack and configure the OU to use in the People Picker for the Subscription
        Write-Host "Assiging Feature Pack and configuring People Picker..."
        
        Set-SPSiteSubscriptionConfig –id $sub -FeaturePack $enterpriseFeatures -UserAccountDirectoryPath $fullOUPath
    
    
    function ProvisionTenant($enterpriseFeatures,$customerName, $customerTenantAdmin, $customerFeatures, $hostingMainURL, $upaProxyName, $mmsProxyName, $foundationFeatures, $ouName, $fullTenantURL, $fullOUPath, $webApp, $sub)
    {
        Write-Host "Provisioning Tenant..."
        Write-Host "Name: $customerName"
        Write-Host "Admin: $customerTenantAdmin"
    
    
    	
    	$a = Read-Host "Are Details ok ?"
     
        # grab the web app
    
    
        # create the "main" member site (we need a site at the root to use Host Headers and Managed Paths in the following cmdlets)
        Write-Host "Creating Root Site..."
        New-SPSite -url "$fullTenantURL" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template BLANKINTERNETCONTAINER#0
    
        # create Tenant Admin site 
        Write-Host "Creating Tenant Admin site..."
        New-SPSite -url "$fullTenantURL/admin" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template tenantadmin#0 -AdministrationSiteType TenantAdministration
    
        # everything else needs standard
        if (!($customerFeatures -eq $foundationFeatures))
        {
            Write-Host "Tenant has SharePoint Server features"
            # create a mysite host
            Write-Host "Creating My Site Host..."
            New-SPSite -url "$fullTenantURL/mysites" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template SPSMSITEHOST#0
    
            # configure the MySites host, MySites path, Naming Resolution and Profile Sync OU for the Subscription
            Write-Host "Configuring Tenant Profile Config..."
            $upaProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $upaProxyName}
    	$upaProxy
            SET-SPSiteSubscriptionProfileConfig -id $sub -SynchronizationOU $ouName -MySiteHostLocation "$fullTenantURL/mysites" -MySiteManagedPath "/mysites/personal" -SiteNamingConflictResolution "None" -ProfileServiceApplicationProxy $upaProxy
    
            # create a site for the Content Type Gallery
            Write-Host "Creating Content Type Gallery..."
            New-SPSite -url "$fullTenantURL/cthub" -SiteSubscription $sub -HostHeaderWebApplication $webApp -owneralias $customerTenantAdmin -template sts#0
    
            # configure the Content Type Gallery for the Subscription
            Write-Host "Configuring Tenant Content Type Gallery..."
            $mmsProxy = Get-SPServiceApplicationProxy | where-object {$_.DisplayName -eq $mmsProxyName}
    	$mmsProxy
            # ContentTypeHub feature activation may fail - if so activate manually
            Set-SPSiteSubscriptionMetadataConfig -identity $sub -serviceProxy $mmsProxy -huburi "$fullTenantURL/cthub" -SyndicationErrorReportEnabled
            Write-Host "Activating Content Type Hub..."
            Enable-SPFeature -Identity ContentTypeHub -url "$fullTenantURL/cthub"
            
            
        }
    
    
        #Set-SPSiteSubscriptionEdiscoveryHub - create an ediscovery hub, requires site - -SearchScope 1 - all of the sub
        
        Write-Host "Tenant Provisioned!"
        return $sub
    
    }
    
    
    #----------------------------------------------------
    #Customer Name will be used in the URL and The site names 
    
    
    
    ProvisionTenant $enterpriseFeatures $customerName $customerTenantAdmin $customerFeatures $hostingMainURL $upaProxyName $mmsProxyName $foundationFeatures $ouName $fullTenantURL $fullOUPath $webApp $sub
    
    

    *** SET Subscription ID command will Work with SP1 of Sharepoint 2010 ***

    Let me know if the above explanation helps.

    Thanks

    Gyan


    Monday, April 09, 2012 9:34 PM
  • Gyan, please re-read the original post.  There is a situation where the subscription is deleted, but the subscription profile config is not. There is no way to currently handle this without directly editing the Profile database.

    http://sharepoint.nauplius.net

    Monday, April 09, 2012 9:36 PM
    Moderator
  • Hi,

    I know..... I agree with you. without editing the data base there is no any option. So please careful before deleting Subscription ID. Delete only site collection associated to Subscription. So that You can use same subscription ID with new tenant site collections. I tried with editing Profile DB and it works for me. :)

    Regards

    Gyan Shukla

    Tuesday, April 10, 2012 9:11 AM
  • Please don't mark your own posts as answers.  It doesn't resolve the original posters issue.

    http://sharepoint.nauplius.net

    Wednesday, April 11, 2012 1:53 PM
    Moderator
  • Here is the solution:

    1. Open SQL Server Management Studio and expand your Tenant Profile DB (it will have ProfileDB in the name).
    2. Look at the Tenants table to find the row that contains your orphaned SynchronizationOU.
    3. Copy the PartitionID (a GUID) of that row (be sure you get the correct one).
    4. Expand Stored Procedures and locate the procedure dbo.Admin_DeletePartition
    5. Right-click it and select Execute Stored Procedure...
    6. Paste the PartitionID into the partitionID parameter's Value field.
    7. Add ' to the beginning and end of the PartitionID GUID you pasted (so it looks like this: '8619e605-762a-4cec-9ae8-0a47cea784dc')
    8. Check the Pass Null Value check box for correlationID
    9. Click OK
    10. IMPORTANT - wait about 5 minutes for the timer service to pick up the changes before reprovisioning your tenant.

    Grant


    Grant Thompson

    Monday, June 04, 2012 7:18 AM
  • Just keep in mind that isn't supported without direction from PSS.

    http://sharepoint.nauplius.net

    Monday, June 04, 2012 1:54 PM
    Moderator
  • Dear Grant,

    thanks for your post... In Sharepoint 2013 I can find this procedure...

    Regards,

    Bernhard

    Saturday, November 23, 2013 12:15 PM