Wednesday, December 14, 2011

Scripts to enable, disable & check Office Web Apps site collections

A. Enabling in all site collections

$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -limit ALL |foreach{Disable-SPFeature $webAppsFeatureId -url $_.URL }

B. Disabling from all site collections

$ConfirmPreference = 'None'
$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -limit ALL |foreach{Disable-SPFeature $webAppsFeatureId -url $_.URL }

C. Enabling in all site collection within MySite Web Apps

$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
Get-SPSite -WebApplication <web app url> -limit all |foreach{Enable-SPFeature $webAppsFeatureId -url $_.URL }

D. Enabling in a single site collection

$webAppsFeatureId = $(Get-SPFeature -limit all | where {$_.displayname -eq "OfficeWebApps"}).Id
$singleSiteCollection = Get-SPSite -Identity <site coll url>
Enable-SPFeature $webAppsFeatureId -Url $singleSiteCollection.URL

E. List sites which doesn't have Office Web Apps activated


Get-SPFeature -Site <site coll url> | where {$_.DisplayName -eq "OfficeWebApps"}

$SiteColls = @(Get-SPSite -WebApplication <web app > -Limit ALL)

foreach ($site in $SiteColls)

{
$feature= Get-SPFeature -Site $site.URL | where {$_.DisplayName -eq "OfficeWebApps"}

if ($feature -eq $Null)
{
write-host "OfficeWebApps is not activated at " , $site.URL
}

}

While activating OWA (using scripts A or C), I got some error which says couldn't activate because exceeded quota. But none of the site collection has exceeded quota. And there was no easy way to identify which site collection was not activated with OWA. Hence, the code (E).