I’ve been wanting to release the SharePoint 2010 version of my STSADM extensions for quite some time but honestly just haven’t had the time to migrate as many as I would have liked. With over 145 STSADM extensions for SharePoint 2007 it was a challenge determining which ones I should focus on initially for the migration.
But today I’m happy to announce my initial release which contains 46 PowerShell cmdlets and 56 STSADM commands specific to SharePoint 2010. Yup, you read right, I’ve decided to maintain support for my STSADM commands and have been migrating them over as I create the equivalent replacement PowerShell cmdlet (though I recommend you don’t use them and suck it up and get used to PowerShell). You should note that there are more STSADM commands than PowerShell cmdlets – that’s because some of the things I was doing with STSADM can now easily be done with out of the box PowerShell cmdlets (I also have new PowerShell cmdlets that do not have an STSADM equivalent – everything new I create will be a cmdlet and I’ll create no new STSADM commands).
It’s going to take me a while to create all the posts needed to explain each cmdlet (assuming I create one at all) so for now I’ve created this simple table which lists all the STSADM commands and PowerShell cmdlets that are available in this initial release (I’ll eventually update my command index page but for now let this serve as the main reference for what is available as of 5/14/2010):
STSADM Commands |
PowerShell Cmdlets |
Notes |
---|---|---|
gl-activatefeature |
Enable-SPFeature2 |
There’s an OOTB Enable-SPFeature cmdlet, this one simple adds some capabilities which were present in my existing STSADM command. |
gl-addaudiencerule |
New-SPAudienceRule |
|
gl-addavailablesitetemplate |
I’ll eventually create a cmdlet for this. | |
gl-adduser2 |
Use the OOTB New-SPUser cmdlet. | |
gl-adduserpolicyforwebapp |
Add-SPWebApplicationUserPolicy |
|
gl-applytheme |
This can be done pretty easily using Get-SPWeb and the ApplyTheme() method of the SPWeb object. | |
gl-backup |
Use the OOTB Backup-SPFarm and Backup-SPSite cmdlets. | |
gl-backupsites |
Backup-SPSite2 |
Extends Backup-SPSite by including IIS settings. |
gl-convertsubsitetositecollection |
ConvertTo-SPSite |
|
gl-copycontenttypes |
Copy-SPContentType |
|
gl-copylist |
Copy-SPList |
|
gl-copylistsecurity |
Copy-SPListSecurity |
|
gl-createaudience |
New-SPAudience |
|
gl-createcontentdb |
Use the OOTB New-SPContentDatabase cmdlet. | |
gl-createpublishingpage |
New-SPPublishingPage |
|
gl-createquotatemplate |
New-SPQuotaTemplate |
|
gl-createwebapp |
Use the OOTB New-SPWebApplication cmdlet | |
gl-deactivatefeature |
Disable-SPFeature2 |
Extends the OOTB Disable-SPFeature cmdlet. |
gl-deleteallusers |
I probably won’t replicate this as it is easily done using the OOTB Remove-SPUser cmdlet. | |
gl-deleteaudience |
Remove-SPAudience |
|
gl-deletelist |
Remove-SPList |
|
gl-deletewebapp |
Use the OOTB Remove-SPWebApplication cmdlet. | |
gl-disableuserpermissionforwebapp |
This is fairly easy to do OOTB so I may not create a cmdlet for it. | |
gl-editquotatemplate |
Set-SPQuotaTemplate |
|
gl-enableuserpermissionforwebapp |
This is fairly easy to do OOTB so I may not create a cmdlet for it. | |
gl-enumaudiencerules |
Export-SPAudienceRules |
|
gl-enumavailablepagelayouts |
Get-SPPublishingPageLayout |
|
gl-enumavailablesitetemplates |
Get-SPAvailableWebTemplates |
|
gl-enumeffectivebaseperms |
This is fairly easy to do OOTB so I may not create a cmdlet for it. | |
gl-enumfeatures |
Use the OOTB Get-SPFeature cmdlet. | |
gl-enuminstalledsitetemplates |
Use the OOTB Get-SPWebTemplate cmdlet. | |
gl-enumpagewebparts |
Get-SPWebPartList |
|
gl-enumunghostedfiles |
Get-SPCustomizedPages |
|
gl-execadmsvcjobs |
Start-SPAdminJob2 |
I honestly need to research this a bit more as I’m not sure it’s necessary anymore but I’ve replicated the functionality in case someone finds it useful. |
gl-exportaudiences |
Export-SPAudiences |
|
gl-exportcontenttypes |
Export-SPContentType |
|
gl-exportlist |
Export-SPWeb2 |
I’ve just extended the Export-SPWeb2 cmdlet to add additional parameters. |
gl-exportlistsecurity |
Export-SPListSecurity |
|
gl-extendwebapp |
Use the OOTB New-SPWebApplicationExtension cmdlet. | |
gl-fixpublishingpagespagelayouturl |
Repair-SPPageLayoutUrl |
|
gl-importaudiences |
Import-SPAudiences |
|
gl-importlist |
Import-SPWeb2 |
I’ve just extended the Import-SPWeb2 cmdlet to add additional parameters. |
gl-importlistsecurity |
Import-SPListSecurity |
|
gl-listaudiencetargeting |
Set-SPListAudienceTargeting |
|
gl-managecontentdbsettings |
Use the OOTB Set-SPContentDatabase cmdlet. | |
gl-propagatecontenttype |
Propagate-SPContentType |
|
gl-publishitems |
Publish-SPListItems |
|
gl-reghostfile |
Reset-SPCustomizedPages |
|
gl-removeavailablesitetemplate |
I’ll eventually create a cmdlet for this (maybe). | |
gl-repairsitecollectionimportedfromsubsite |
Repair-SPSite |
|
gl-replacewebpartcontent |
Replace-SPWebPartContent |
|
gl-setbackconnectionhostnames |
Set-SPBackConnectionHostNames |
|
gl-setselfservicesitecreation |
Not sure if I’ll migrate this or not. | |
gl-syncquotas |
Set-SPQuota |
|
gl-tracelog |
Use the OOTB Set-SPDiagnosticConfig cmdlet. | |
gl-unextendwebapp |
Use the OOTB Remove-SPWebApplication cmdlet. | |
Get-SPAudience |
||
Get-SPAudienceManager |
||
Get-SPContentType |
||
Get-SPFile |
||
Get-SPLimitedWebPartManager |
||
Get-SPList |
||
Get-SPPublishingPage |
||
Get-SPQuotaTemplate |
||
Set-SPAudience |
For those that know a thing or two about cmdlet development you might be
interested in knowing that I am dynamically generating the help XML file for the cmdlets. If you download the source you’ll find a class which uses reflection to interrogate the assembly and dynamically build the help file just prior to building the WSP package. This saved me literally days of hand editing XML.
You can download the source and WSP files here or from the Downloads page:
- SharePoint 2010 PowerShell Cmdlets Source Code
- SharePoint 2010 Server Cmdlets WSP
- SharePoint 2010 Foundation Cmdlets WSP
After you deploy the package you can type “help <cmdlet name>” to get detailed help about each cmdlet, including parameter descriptions and example usage. If you want to see the list of cmdlets installed type the following:
gcm | where {$_.DLL –like "*lapointe*"}
As always, your use of these cmdlets/stsadm commands is at your own risk – I do as much testing as I can but every environment is different and there’s simply not enough time in a day. If you have any suggestions or feedback please don’t hesitate to leave a comment – I appreciate all of them!
18 thoughts on “Announcing My SharePoint 2010 PowerShell Cmdlets & STSADM Commands Now Available for Download”
Hey, nice work on sharing useful info on SharePoint automation using the Powershell.
I work on the AD side of the house and time permitting blog on Powershell for Active Directory.
Thought I’d stop in and say Hello.
Cheers,
Scottie
We’re relieved that you are working on 2010 versions of your stsadm extensions as we rely on them pretty much every day! An important one for us is gl-setnavigationnodes – any idea when you’ll be able to get that one updated?
I don’t have a timetable right now – just working on them when I have time and right now there’s just not enough of it.
I’m sure we all have our favorite of your commands, but my vote would be gl-importprofileproperties. Oh, the time that command saves me.
Thanks Gary!
Great post … Thanks for sharing ….
Homework Help | Assignment Help
Great job! The ConvertTo-SPSite will be especially useful I believe.
I was wondering how we could submit code changes to you? Going to change the ConvertTo-SPSite function to allow a specifiable temporary folder. Right now it writes to C:\users\User\AppData\Local\Temp\Guid which depending on your server setup your C: drive probably doesn’t have enough space to split large collections up.
Thanks! You can always send me the code via email and if the change makes sense I’ll to incorporate it.
Hi Gary,
I have run into the issue of importing a wiki (publishing) site, where page layouts get screwed up. I’m hoping Repair-SPPageLayoutUrl will be able to fix it. However, I just want to run it on a particular subsite, and not risk affecting other sites. What’s the command structure I should use? Really hoping this works, as there are LOTS of pages to fix :|.
Thanks.
If you pass in the URL to your sub-site using the -Web parameter it will just affect that web (so just the Pages library in that one Web; it doesn’t recurse to child Webs). You can also use the -Page parameter to update just one page. If you view the help for the cmdlet you’ll see more examples and details about how you can use it; here’s an example showing how to fix just a single web:
Get-SPWeb "http://server_name" | Repair-SPPageLayoutUrl
Which is the same as:
Repair-SPPageLayoutUrl -Web "http://server_name"
Just a comment – couldn’t figure out why Get-SPAudience and the other commands kept returning No User Profile Application available to service the request. Contact your farm administrator. but it was simple really – needed to grant myself permission on the User Profile Service Application.
Thank you for all the contribution with your tools – they have been useful on many occasions!
Iain
Hi,
I not able to find copy site column feature like in SP2007 version. May i know whether it is totally not available or there will be an enhancement in the future to include this?
Thanks!
It’s on the list of things to do.
Hey Gary,
I’m trying to use your Copy-SPContentType cmdlet, but I keep getting an error saying that it can’t copy the Information Rights Management policies. Is this a limitation of the cmdlet?
I’ve not done a whole lot of testing of that specific piece of the cmdlet as this cmdlet was a more or less straight migration from my 2007 code so it’s possible that there’s something with 2010 that I just didn’t account for. Can you provide the specific error?
Hi Gary, Excellant.. no words to say. Just curious to know about,how to input params from command prompt. Like DBScript -Action “TestSPContentDatabase” -Outputfiles “e:\output\script.ps1” -logfolder “e:\logs
DBscript is custom command let, which has ben developed in .net as per your code examples. Always my command let is asking to provide each input values and then executing accordingly. I am not able to type full command my self. How do we do that?
I’m not sure I’m understanding the issue. Can you try to restate it?
Comments are closed.