PowerShell Script To Change Managed Account Password

Of all days in the week, on Sunday [August 21, 2011] I decided to tease my SharePoint 2010 development environment! I decided to change all the SharePoint 2010 Service Account(s)password.

Thank you Microsoft for introducing the managed accounts, else I would be clicking away for a long time, having to go through each application pool to change the password (map this scenario to MOSS 2007 or WSSv3). With managed accounts associated with application pools, it was a matter of changing the password for the managed account and it would ‘cascade’ down…

Read the rest of this entry »

How To Create SharePoint 2010 Site Collection In Its Own DB

Early this week on site deploying SharePoint 2010, the client wanted to create few site collections for their development team. He tried to create using the Central Administration and could not see any options for creating SharePoint site collections in their own databases!

Well, that’s not news to all of us in the SharePoint World! Is it?

Read the rest of this entry »

PowerShell To Change SharePoint Diagnostic Log File Location

The following PowerShell cmdlet will get all the diagnostic configuration values

Get-SPDiagnosticConfig

clip_image001

If you want to change the location of your diagnostic configuration log use the following PowerShell cmdlet

Set-SPDiagnosticConfig -LogLocation D:\SharePointLogs\

Help! Farm Admin cannot execute cmdlets in SP 2010 Management Shell

In order to execute farm level cmdlets in SharePoint Management Shell you will need to be given Shell Admin access. Even if you are a farm administrator and you have not been given Shell Admin Access, then you won’t be able to execute farm administrative operation using PowerShell. There are lots of operations that you cannot do via the Central Administration GUI and for which you will require Shell Admin Access.

List who has SP Shell Admin Access

Before you get started with addition, it would be good to check who has Shell Admin access using the following PowerShell cmdlet

get-spshelladmin

clip_image001

Let’s check who is in the farm administrator group for http://server

clip_image002

Even though I am a farm administrator, I could not use SharePoint Management Shell to get a list of users who have SPShellAdmin access.

clip_image003

Give user SP Shell Admin Access

To add a user as Shell Admin, use the following PowerShell cmdlet (logged in as the account that has SPShellAdmin access)

Add-SPShellAdmin -username alpesh

Or simply type Add-SpShellAdmin and press enter. You will be prompted to enter the username! Then type get-spshelladmin to see if you have successfully added the user as SPShellAdmin

clip_image004

 

Remove SP Shell Admin Access for a user

To remove a user as Shell Admin, use the following PowerShell cmdlet

Remove-SPShellAdmin –username alpesh

Or

Or simply type Remove-SPShellAdmin and press enter. You will be prompted to enter the username!

clip_image005

PowerShell To List Site Template

SharePoint 2010 Management Shell makes it easier to get a list of Site Templates installed in the farm and also creating sites using the names is straight forward.

To get a list of all globally installed site templates use the following PowerShell cmdlet

get-spwebtemplate

clip_image001

To get the basic information about all the STS template, use the following PowerShell cmdlet

get-spwebtemplate “STS*”

clip_image002

To get the basic information about all the SPS template, use the following PowerShell cmdlet

get-spwebtemplate “SPS*”

clip_image003

PowerShell To List Service Applications

Service Applications is one of the newest additions in SharePoint 2010 arsenal of features. As again you can manage Service Applications via the SharePoint 2010 Management Shell. In the illustration under, you will see how we can get a list of Service Applications deployed.

Get-SPServiceApplication cmdlet lists all service applications in a farm with their Display Name, TypeName and ID

clip_image002

Now type the same command piped with Select Id, Name to get these results

clip_image004

PowerShell To List Feature Definitions

Get-spfeature gets the SharePoint features based on a given scope.

This cmdlet behaves differently at each scope, getting the enabled Features at each level. There are 4 levels of scope

· Farm

· WebApplication

· Site (Site Collection)

· Web (Site)

get-spfeature -farm (gets all the enabled Feature in the farm)

get-spfeature -webapplication http://server (gets all enabled the Features in the Web application)

get-spfeature -site http://server/sites/IT (gets all the enabled Features on the site collection)

get-spfeature -site -sandboxed (gets all installed the Feature definitions on the site)

get-spfeature -web (gets all the enabled Features in the Web)

If no scope is provided, all installed Features are returned.

get-spfeature (gets all the installed Feature definitions in the farm)

clip_image002

The list will scroll by so use any of the following commands

get-spfeature | more (using more command stops the list from scrolling to end)

get-spfeature |select displayname, scope (using select displayname, scope will remove the id column)

get-spfeature | sort scope | select displayname, scope | more (sort scope command will sort the feature based on their scope)

clip_image003

get-spfeature -Limit ALL | Where-Object {$_.Scope -eq “SITE”}

This will get a list of all installed “SITE” scoped Feature. Replace Site with Web or Farm to see the list

clip_image004