Wednesday, November 30, 2011

Userful Powershell / STSAdm Commands

During my SP2010 upgrade process, on of the challenges I have is constently running PowerShell scripts and piping the results to a file so that I can parse and create new scripts against the results.  I have been doing it using the old way... like using "> test.txt".  Than I found ou that you can use the CovertTo and Export options with better and consistent results.  Below are a few examples:


TEST-SPContentDatabase -name MyContentDB -webapplication http://intranet -serverinstance MyDBServer  | ConvertTo-Html | Out-file intranet.html


TEST-SPContentDatabase -name MyContentDB -webapplication http://intranet -serverinstance MyDBServer  | ConvertTo-CSV -Delimiter "~" | Out-file intranet.csv


TEST-SPContentDatabase -name MyContentDB -webapplication http://intranet -serverinstance MyDBServer  | Export-CLIXML intranet.xml



Other PowerShell Commands useful around Upgrade

Get-Command -noun SP* - similar to stsadm -help
Test-SpContentDatabase – discussed in this post
Upgrade-SPContentDatabase – to resume failed upgrades
Upgrade-SPEnterpriseSearchServiceApplication – Upgrade Search
Upgrade-SPSingleSignOnDatabase – Upgrade SSO
Mount-SPContentDatabase – Used to attach a database or multiple parallel databases to the farm. Essentially is nearly the same as the STSADM –o addcontentdatabase.   If you‘re doing parallel content database attach for example, this PowerShell method is recommended. You‘d simply run each ofthese in different command/management windows.
Upgrade-SPProjectWebInstance – Upgrade Project Server databases. Obviously this only applies with Project Server deployments, but I know there are definitely many out there.
Upgrade-SPEnterpriseSearchServiceApplication – Upgrade the Search Service Application Instance. This commandlet it designed to upgrade the content sources and configuration of search and to upgrade it into the new service application.
Set-SPSite  -- Can use this command to setup site collection admins



STSADM Commands useful around preparing for Upgrade

stsadm -o ExportIPFSAdminObjects
stsadm -o MergeContentDB
stsadm -o EnumAllWebs
stsadm -o DatabaseRepair [-deletecorruption]
stsadm -o DeleteSite [-force] [-gradualdelete]
stsadm -o DeleteWeb [-force]
stsadm -o ForceDeleteList
stsadm -o VariationsFixupTool
stsadm –o Upgrade (Used for build to build upgrades, including service packs.)

No comments:

Post a Comment