Edit This is for SharePoint 2007
I have this powershell script:
## Reference to SharePoint DLL
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
## Probable location of sharepoint STSADM utility program
$stsadm = "$env:programfiles\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE"
############################################
# Activate-feature-onSite [-feature |-url ]
############################################
$spsite=[Microsoft.SharePoint.SPSite]("site-url");
foreach($web in $spsite.AllWebs)
{
$websiteurl= $web.url
$sResult = &stsadm -o deactivatefeature -id '6C45F6A6-17CC-49f4-A30F-4424C7DF3563' -url $websiteurl -force
if(!($sResult -like "*Operation completed successfully*")){
Write-Host -ForegroundColor "red" -BackgroundColor "white" "Deactivation of feature ‘’ for ‘$websiteurl’ Failed!"
}
else{
Write-Host -ForegroundColor "blue" -BackgroundColor "white" "Deactivation of feature 6C45F6A6-17CC-49f4-A30F-4424C7DF3563 for ‘$websiteurl’ Worked! `n $sResult"
}
}
$spsite.Dispose()
And before it is deployed id like to run it by some pros and see if I am correctly disposing of the site, and if i should dispose of the webs aswell.
Ive never used powershell before, so im not sure if it follows the regular disposal practices, or if it does the disposal itself, etc.
Any feedback would be welcome!