function ActivateWebFeatureByWebUrlAndFeatureId($webUrl, $featureId) {
    if(!(Get-SPFeature $featureId -Web $webUrl -ErrorAction:SilentlyContinue))
    {
        Enable-SPFeature $featureId -Url $webUrl
        if(Get-SPFeature $featureId -Web $webUrl -ErrorAction:SilentlyContinue)
        {
            Write-Host "Feature " $featureId " activated sucsesfully"
        }
    }
    else
    {
        Write-Host "Feature " $featureId "already active!"
    }    
}

function DeactivateWebFeatureByWebUrlAndFeatureId($webUrl, $featureId) {	
    if((Get-SPFeature $featureId -Web $webUrl -ErrorAction:SilentlyContinue)) #or -Site, -WebApplication, -Farm
    {
        Disable-SPFeature $featureId -Url $webUrl -Confirm:$false
        sleep -s 2
        if(!(Get-SPFeature $featureId -Web $webUrl -ErrorAction:SilentlyContinue))
        {
            Write-Host "Feature " $featureId " deactivated sucsesfully"
        }
    }
    else
    {
        Write-Host "Feature " $featureId "already unactive!"
    }    
}

# Инициализация переменных
$siteUrl = "http://sps2010dev2:100"
$featureId = "afa934c0-ebde-4703-884b-77c296e72136"

cls
start-transcript ExportDataAndUninstall.log

Start-SPAssignment

$site = Get-SPSite ($siteUrl) -ErrorAction Stop
foreach ($web in $site.AllWebs) 
{	
	Write-Host ($web.Url)
	#ActivateWebFeatureByWebUrlAndFeatureId $web.Url $featureId
	DeactivateWebFeatureByWebUrlAndFeatureId $web.Url $featureId
}

stop-transcript
Stop-SPAssignment -global
