1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ############################################################################################################### ##Deactivate a Feature on all Sites for a web application ### ## http://Blog.IsaacBlum.com ## ############################################################################################################### ############################################################################################################### #Create function deactivatefeature function deactivatefeature{ ## Reference to SharePoint DLL [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") ## Location of sharepoint STSADM utility program, You may need to change this $stsadm = "$env:programfiles\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE" #Ask for WebApp Root url to enumerate $url = Read-Host "Please enter root url of WebApplication" #Enumerate available features in SharePoint Farm write-host -foregroundcolor green " Below are the available features in SharePoint Farm" &stsadm -o scanforfeatures #Ask for Feature Name Write-Host "Please enter feature name that will be deactivated at all Sites and Sub-Sites of the specified application" $feature = Read-Host "do not add the \feature.xml. ex: NewsGator.SocialSites.SiteSkin" #Returning info for use in remainder of script $webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url) #List Sites Affected write-host -foregroundcolor green " The feature will be deactivated on the following Sites:" foreach ($site in $webapp.Sites) { # write-host $webapp.Name foreach ($web in $site.AllWebs) { write-host $web.URL }} ##Actvate Feature on all Sites foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { $sResult = &stsadm -o deactivatefeature -name $feature -url $web.URL -force if(($sResult -like "*Operation completed successfully*")){ write-host -foregroundcolor green "Feature Deactivated : "$web.URL} else { Write-Host -ForegroundColor "red" -BackgroundColor "white" "Deactivate of feature '$feature' for" $web.URL "Failed! `n $sResult" } } } } ############################################################################################################### ############################################################################################################### ############################################################################################################### |
Archive for December, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ########################################################## ##Actvate a Feature on all Sites for a web application ### ## http://Blog.IsaacBlum.com ## ########################################################## ########################################################## #Create function activatefeature function activatefeature{ ## Reference to SharePoint DLL [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") ## Location of sharepoint STSADM utility program, You may need to change this $stsadm = "$env:programfiles\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE" #Ask for WebApp Root url to enumerate $url = Read-Host "Please enter root url of WebApplication" #Enumerate available features in SharePoint Farm write-host -foregroundcolor green " Below are the available features in SharePoint Farm" &stsadm -o scanforfeatures #Ask for Feature Name Write-Host "Please enter feature name that will be activated at all Sites and Sub-Sites of the specified application" $feature = Read-Host "do not add the \feature.xml. ex: %featurename%" #Returning info for use in remainder of script $webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url) #List Sites Affected write-host -foregroundcolor green " The feature will be actvated on the following Sites:" foreach ($site in $webapp.Sites) { # write-host $webapp.Name foreach ($web in $site.AllWebs) { write-host $web.URL }} ##Actvate Feature on all Sites foreach ($site in $webapp.Sites) { foreach ($web in $site.AllWebs) { $sResult = &stsadm -o activatefeature -name $feature -url $web.URL -force if(($sResult -like "*Operation completed successfully*")){ write-host -foregroundcolor green "Feature Actvated : "$web.URL} else { Write-Host -ForegroundColor "red" -BackgroundColor "white" "Activate of feature '$feature' for" $web.URL "Failed! `n $sResult" } } } } ######## ######## ######## |
Add the below code to any PowerShell script to call a pause.
This code is made possible by http://blogs.msdn.com/powershell/archive/2007/02/25/pause.aspx
1 2 3 4 5 6 | function Pause ($Message="Press any key to continue...") { Write-Host -NoNewLine $Message $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host "" } |
Thanks to http://blogs.msdn.com/sharepoint/archive/2007/03/02/be-wary-when-removing-or-replacing-the-my-site-link.aspx and http://suguk.org/forums/thread/6898.aspx.
I needed a way of adding a link back to the portal site, when in my MySite. I went to “Personalization site links”. Added a link but every time it would add the http://%yoururl%/default.aspx?MySiteView=1 . Made me crazy. Anyway thanks to the folks that bloged about it first.








