The below code doesnt have any restrictions of sql services which are in stopped mode. It can change the password for all the sql services that are running and skip the password change for the sql services that are in stopped state.
Here, ComputerListAll.txt contains the list of all the servers that are running sql services. Using the ForEach helps us to change the password simultaneously for all the machines.
$username = "ServiceAccountName"
$password = "ServiceAccountPassword"
$computers = get-content "C:\Powershell\computerlistall.txt"
forEach ($computer in $computers)
{
$sqlservices = Get-WmiObject -Namespace root\Microsoft\SqlServer\ComputerManagement10 -computername $computer -Class SqlService `
| Where-Object {$_.StartName -eq $username}
$i = $sqlservices.Count
For ($a = 0 )
{
if ($a -lt $i -and $sqlservices[$a].state -ne 1)
{
$sqlservices[$a].stopservice()
$sqlservices[$a].setserviceaccount($username,$password)
$sqlservices[$a].startservice()
}
else
{
$a++
}
if ($a -eq $i)
{
break
}
if ($sqlservices[$a].State -ne 1)
{
$sqlservices[$a].stopservice()
$sqlservices[$a].setserviceaccount($username,$password)
$sqlservices[$a].startservice()
$a++
}
else
{
$a++
}
if ($a -eq $i)
{
break
}
}
}
Write-Host "SQL passwords changed completely"
Wednesday, June 17, 2009
Tuesday, June 16, 2009
What are content types in Sharepoint?
Concept of content types
Content types are objects we create and activate typically at the level of the site collection containing the definition of one specific type of content that we want to make it available to the sharepoint users via the lists and document library containers. Content types are pacakged definitions of what we intend to store in sharepoint sites. A content type definition can include plenty of things such as columns, workflows, information management policies, document templates and more.
The creation of content type can be done -
1> in the browser.
2> delivered via a feature.
3> programmatically via object model.
Once the content type is defined, we can go to any lists and document libraries and configure the container to allow the user to create new item or document based on this content type.
Content types are objects we create and activate typically at the level of the site collection containing the definition of one specific type of content that we want to make it available to the sharepoint users via the lists and document library containers. Content types are pacakged definitions of what we intend to store in sharepoint sites. A content type definition can include plenty of things such as columns, workflows, information management policies, document templates and more.
The creation of content type can be done -
1> in the browser.
2> delivered via a feature.
3> programmatically via object model.
Once the content type is defined, we can go to any lists and document libraries and configure the container to allow the user to create new item or document based on this content type.
Monday, June 8, 2009
Windows Powershell - Changing SQL services password if all sql services are running
Here We will be using powershell to change the password of sql services present on your machine. The below code is for the machine that hosts both sql 2008 and sql 2005. it is important to know the namespace and the class being used for the code to work properly. Note that, here all the sql services including sql agents are running on the service account. If any sql services are stopped and the logonas is still in the service account name, make sure that you change it to local system and the service is stopped.
$username = "Service Account"
$password = "Password"
In the above section we will set the username and the password as an object.
$sqlservices = Get-WmiObject -Namespace root\Microsoft\SqlServer\ComputerManagement10 -Class SqlService `
Where-Object {$_.StartName -eq $username}
For $sqlservices, we are getting the list of sql services objects which are running under the username.
$i = $sqlservices.Count
$i gives you the count of the sql services running on your machine. You can verify the same by going to services.msc using the RUN on the machine. Once that is confirmed, proceed further.
For ($a = 0 )
{
$sqlservices[$a].stopservice()
$sqlservices[$a].setserviceaccount($username,$password)
$sqlservices[$a].startservice()
$a++
As the sql services object are stored as a array in $sqlservices, we need to call each object present inside the array, then stop the service, reset the password and then start the service. Whatever is mentioned above goes in a loop, reseting the password one by one.
if ($a -eq $i)
{
break
}
}
Once the object present in the array finishes i.e. it maps with the number of objects present and then it comes out of the loop.
Write-Host "SQL passwords changed completely"
The above line just notifies that the sql password has been changed.
To run the script as a whole, copy the code in italics onto powershell command and execute it.
$username = "Service Account"
$password = "Password"
In the above section we will set the username and the password as an object.
$sqlservices = Get-WmiObject -Namespace root\Microsoft\SqlServer\ComputerManagement10 -Class SqlService `
Where-Object {$_.StartName -eq $username}
For $sqlservices, we are getting the list of sql services objects which are running under the username.
$i = $sqlservices.Count
$i gives you the count of the sql services running on your machine. You can verify the same by going to services.msc using the RUN on the machine. Once that is confirmed, proceed further.
For ($a = 0 )
{
$sqlservices[$a].stopservice()
$sqlservices[$a].setserviceaccount($username,$password)
$sqlservices[$a].startservice()
$a++
As the sql services object are stored as a array in $sqlservices, we need to call each object present inside the array, then stop the service, reset the password and then start the service. Whatever is mentioned above goes in a loop, reseting the password one by one.
if ($a -eq $i)
{
break
}
}
Once the object present in the array finishes i.e. it maps with the number of objects present and then it comes out of the loop.
Write-Host "SQL passwords changed completely"
The above line just notifies that the sql password has been changed.
To run the script as a whole, copy the code in italics onto powershell command and execute it.
Friday, June 5, 2009
Error in Eventviewer - Message: Error during encryption or decryption. System error code 0.
The error "Message: Error during encryption or decryption. System error code 0." comes up in sharepoint if the updation of password hasn't taken place properly. In a farm when you have two or more front end servers we become highly dependent on the STSADM command to update the service account credentials. There are two ways to change the password for these kind of scenarios.
1> Using the UI.
2> Using the STSADM commands.
Using the UI
The places where you need to go for a service account password change is as follows -
a> Go for the password change on Sharepoint machines first.
b> In the sharepoint, go to the services using the services.msc in the RUN and then change the password of the services related to Sharepoint.
c> Open the IIS. check for the app pools that are running on the service account. Change the password there. Recycle the App Pools.
c> Open the central admin page then go to operations tab. Then click on services on server link. Then click on the services that are running and change the password there.
d> Click on the Shared Services link on the left side pane. that will open up the SSP which you have configured. Select the SSP and click on Edit properties. There also the password must be updated.
e> Finally, open the SSP and change the password in the default access account.
When we are following the password change using the STSADM commands, try to follow the steps as mentioned below.
Using the STSADM commands
Central Admin
1. stsadm -o updatefarmcredentials -userlogin [Service Account]-password [Password]
IISRESET /NOFORCE
NOTE:
One or more errors deploying administration application pool credentials. Please check the application event log and fix manually. This command must either be used on a server where Central Administration is running, or you must specify the -local parameter.
There was an error encrypting or decrypting credentials. Either a credential update is currently being performed, or you must update the farm account credentials on this server before you can perform this task. Run the above command with -local parameter
App pool password change
2. stsadm -o updateaccountpassword -userlogin [Service Account]-password [Password] -noadmin
IISRESET /NOFORCE
NOTE: in case there is an error in the above step saying "please retry manually”. Re-run the above script after opening the Central Admin site.
WSS Search Help
3. stsadm.exe -o spsearch -farmserviceaccount [Service Account]-farmservicepassword [Password]
4. stsadm.exe -o spsearch -farmcontentaccessaccount [Service Account]-farmcontentaccesspassword [Password]
SSP
5. stsadm.exe -o editssp -title [Name of SharedServices] -ssplogin [Service Account]-ssppassword [Password]
Office SharePoint Service Search
6. stsadm.exe -o osearch -farmserviceaccount [Service Account] -farmservicepassword [Password]
7. Finally, Manually change the password for “Default content access account”
1> Using the UI.
2> Using the STSADM commands.
Using the UI
The places where you need to go for a service account password change is as follows -
a> Go for the password change on Sharepoint machines first.
b> In the sharepoint, go to the services using the services.msc in the RUN and then change the password of the services related to Sharepoint.
c> Open the IIS. check for the app pools that are running on the service account. Change the password there. Recycle the App Pools.
c> Open the central admin page then go to operations tab. Then click on services on server link. Then click on the services that are running and change the password there.
d> Click on the Shared Services link on the left side pane. that will open up the SSP which you have configured. Select the SSP and click on Edit properties. There also the password must be updated.
e> Finally, open the SSP and change the password in the default access account.
When we are following the password change using the STSADM commands, try to follow the steps as mentioned below.
Using the STSADM commands
Central Admin
1. stsadm -o updatefarmcredentials -userlogin [Service Account]
IISRESET /NOFORCE
NOTE:
One or more errors deploying administration application pool credentials. Please check the application event log and fix manually. This command must either be used on a server where Central Administration is running, or you must specify the -local parameter.
There was an error encrypting or decrypting credentials. Either a credential update is currently being performed, or you must update the farm account credentials on this server before you can perform this task. Run the above command with -local parameter
App pool password change
2. stsadm -o updateaccountpassword -userlogin [Service Account]
IISRESET /NOFORCE
NOTE: in case there is an error in the above step saying "please retry manually”. Re-run the above script after opening the Central Admin site.
WSS Search Help
3. stsadm.exe -o spsearch -farmserviceaccount [Service Account]
4. stsadm.exe -o spsearch -farmcontentaccessaccount [Service Account]
SSP
5. stsadm.exe -o editssp -title [Name of SharedServices] -ssplogin [Service Account]
Office SharePoint Service Search
6. stsadm.exe -o osearch -farmserviceaccount [Service Account] -farmservicepassword [Password]
7. Finally, Manually change the password for “Default content access account”
Tuesday, June 2, 2009
Your current security settings donot allow this file to be downloaded.
This error comes up when the Internet Explorer is at its best in securing your machine and network. Inorder to download anything from the internet which is essential, you need to change the settings in the internet explorer.
1> Open the Internet Explorer
2> Click on Tools --> Internet Options
3> select the security tab.
4> The zone selected should be internet as you want to download a file from the net.
5> Then click on "Custom Level" button.
6> Another box comes up. Then scroll down and check for "downloads" setting.
7> Enable File download.
8> Enable Automatic Prompting for File downloads.
9> Close the IE and open again.
This should help you in downloading the file from the net.
1> Open the Internet Explorer
2> Click on Tools --> Internet Options
3> select the security tab.
4> The zone selected should be internet as you want to download a file from the net.
5> Then click on "Custom Level" button.
6> Another box comes up. Then scroll down and check for "downloads" setting.
7> Enable File download.
8> Enable Automatic Prompting for File downloads.
9> Close the IE and open again.
This should help you in downloading the file from the net.
Subscribe to:
Posts (Atom)