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:programfilesCommon FilesMicrosoft SharedWeb Server Extensions12BINSTSADM.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 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:programfilesCommon FilesMicrosoft SharedWeb Server Extensions12BINSTSADM.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.
Thanks goes to the following people/sites: http://blogs.msdn.com/dansellers/archive/2005/11/09/491152.aspx & http://windowsitpro.com/Web/article/articleid/9738/extending-the-user-class-in-the-ad-schema.html
Enable Password Question and Password Reset:
When these attributes are set to true in the web config file as seen below, the user is required to provide an answer to a Password Question when the password is first created. When the user resets their password, they will also be required to provider the answer they supplied to the Password Question when the password was first created.
<membership defaultProvider=”ADAMProvider”>
<providers>
<add
connectionStringName=”ADCnString”
connectionUsername=”CN=ADAdmin,OU=Users,O=ADAuth”
connectionPassword=Pass@word1
connectionProtection=”None”
requiresQuestionAndAnswer=”true”
enablePasswordReset=”true” …
Mapping Password Question and Answer Attributes:
Both the Password Question and the Answer will be saved in the SQL Server, Active Directory, or the Active Directory Application Mode (ADAM) depending upon the provider you are using. However, if you are using the Active Directory Provider you will be required to modify the schema of either the Active Directory or ADAM to store the Password Question and Password Answer. Then in the web config file you will need map the Password Question and Answer’s attributes to the modified schema as shown below:
<membership defaultProvider=”ADAMProvider”>
<providers>
<add
connectionStringName=”ADCnString”
connectionUsername=”CN=ADAdmin,OU=Users,O=ADAuth”
connectionPassword=Pass@word1
connectionProtection=”None”
requiresQuestionAndAnswer=”true”
enablePasswordReset=”true”
attributeMapPasswordQuestion=”PwdQuestion”
attributeMapPasswordAnswer=”PwdAnswer” …
Example Schema Modification:
Creating the PwdQuestion and PwdAnswer attribute as defined above is not difficult in the ADAM ADSI Edit tool under the Schema configuration, but initially it takes a while to figure out what values required by the attribute schema wizard. Below is an example of the values that you can use in your Active Directory or ADAM directory.
cn: PwdQuestion
OMSyntax: 64 (for Unicode string)
lDAPDisplayName: PwdQuestion
isSingleValued: TRUE
AttributeSyntax: 2.5.5.12 (Active Directory syntax type of Unicode)
AttributeID: 1.2.840.113556.1.6.1.1.6221 (Unique Object Identifiers (OIDs))
cn: PwdAnswer
OMSyntax: 64 (for Unicode string)
lDAPDisplayName: PwdAnswer
isSingleValued: TRUE
AttributeSyntax: 2.5.5.12
AttributeID: 1.2.840.113556.1.6.1.1.6222
Schema modifications:
Creating the Failed Password Count, Failed Password Answer Time and Failed Password Locked Out Time attributes–as defined below–is not difficult in the ADAM ADSI Edit tool under the Schema configuration, but initially it takes a while to figure out what values are required by the attribute schema wizard. Below is an example of the values that you can use in your Active Directory or ADAM directory.
cn: FailedPwdCount
OMSyntax: 2 (for type integer)
lDAPDisplayName: FailedPwdCount
isSingleValued: TRUE
AttributeSyntax: 2.5.5.9 (Active Directory syntax type of Unicode)
AttributeID: 1.2.840.113556.1.6.1.1.6223 (Unique Object Identifiers (OIDs))
cn: FailedPwdAnswerTime
OMSyntax: 65 (for Large integer/Interval)
lDAPDisplayName: FailedPwdAnswerTime
isSingleValued: TRUE
AttributeSyntax: 2.5.5.16
AttributeID: 1.2.840.113556.1.6.1.1.6224
cn: FailedPwdLockOutTime
OMSyntax: 65 (for Large integer/Interval)
lDAPDisplayName: FailedPwdLockOutTime
isSingleValued: TRUE
AttributeSyntax: 2.5.5.16
AttributeID: 1.2.840.113556.1.6.1.1.6225
Modify Web Config File:
When using the Active Directory Provider you will be required to modify the Web config to map the Failed Password Answer Count, Failed Password Answer Time and Failed Password Answer Lockout Time attributes to the appropriate User’s properties (as created above) in either your Active Directory or ADAM.
<membership defaultProvider=”ADAMProvider”>
<providers>
<add
connectionStringName=”ADCnString”
connectionUsername=”CN=ADAdmin,OU=Users,O=ADAuth”
connectionPassword=Pass@word1
connectionProtection=”None”
requiresQuestionAndAnswer=”true”
enablePasswordReset=”true”
attributeMapPasswordQuestion=”PwdQuestion”
attributeMapPasswordAnswer=”PwdAnswer”
attributeMapFailedPasswordAnswerCount=”FailedPwdCount” attributeMapFailedPasswordAnswerTime=”FailedPwdAnswerTime”
attributeMapFailedPasswordAnswerLockoutTime=”FailedPwdLockOutTime”
(Adding the attributes to the user clasee)
From the Schema Console, click the Class folder. Scroll down to the User class, right-click it, and select Properties. On the user Properties dialog box, click the Attributes tab, which Figure 7 shows. Click Add, then choose the Gender attribute. Click OK twice, and you’ve successfully added the Gender attribute to the User class.
Thanks to http://www.pgrconsulting.com/useful_p_and_t.htm
– Create the temp table for further querying
CREATE TABLE #temp(
rec_id int IDENTITY (1, 1),
table_name varchar(128),
nbr_of_rows int,
data_space decimal(15,2),
index_space decimal(15,2),
total_size decimal(15,2),
percent_of_db decimal(15,12),
db_size decimal(15,2))
– Get all tables, names, and sizes
EXEC sp_msforeachtable @command1=”insert into #temp(nbr_of_rows, data_space, index_space) exec sp_mstablespace ‘?’”,
@command2=”update #temp set table_name = ‘?’ where rec_id = (select max(rec_id) from #temp)”
– Set the total_size and total database size fields
UPDATE #temp
SET total_size = (data_space + index_space), db_size = (SELECT SUM(data_space + index_space) FROM #temp)
– Set the percent of the total database size
UPDATE #temp
SET percent_of_db = (total_size/db_size) * 100
– Get the data
SELECT *
FROM #temp
ORDER BY total_size DESC
– Comment out the following line if you want to do further querying
DROP TABLE #temp

