Skip to main content

Posts

Showing posts from January, 2014

How to get the List of all databases in SharePoint 2010 using Powershell

To retrieve a list of SharePoint databases.  When you run Get-SPDatabase , you are provided the Name, Id, and Type of SharePoint databases. PS C:\> Get-SPDatabase If you run Get-SPDatabase | Select Name, only the database name is brought in entirety. PS C:\> Get-SPDatabase | Select Name If you want to save the output to a file. Then use Out-File parameter. Like that : PS C:\>Get-SPDatabase | Sort-Object Name | Select Name | Out-File C:\SharePointDBList.txt The below script builds a script that returns all the databases where the name doesn’t match the name from the SharePoint databases. $file = New-Item -type file "C:\SPDBs.txt" -force add-content $file "select name from sys.databases where name not in (" Get-SPDatabase | foreach-object{add-content $file $_.Name} add-content $file ")" ii $file

How to get the databases that belonged to a specific User Profile Service Application in SharePoint 2010/2013

All of the User Profile Service Application databases for the User Profile Service Application object are marked as Internal properties, in other words, not easily accessible. So how can we get the databases that belong to a particular User Profile Service Application? First, we need to know the properties that we’re after, and for that I always use the handy .NET Reflector. The properties for the User Profile Service Application Databases are: 1. ProfileDatabase 2. SocialDatabase 3. SynchronizationDatabase #Get the named User Profile Service Application $upsa = Get-SPServiceApplication | where {$_.Name -eq "User Profile Service Application"} #Get the non-public Properties of the User Profile Service Application object $propData = $upsa.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)  #Get the Social database Name, ID, and Type $socialProp = $propData | where {$_.Name -eq "SocialDatabase"} $so...

How to debug Powershell Scripts for SharePoint 2010/2013

Using Windows powershell ISE , you can debug the powershell scripts. Windows Powershell ISE tool  come along with the installation of windows server 2012. To debug the script select the line of code where you want to place the breakpoint and then go to " Debug " menu option and click on " Toggle BreakPoint" or F9 . This will add the breakpoint. -  When you execute the script by pressing F5 keyword, once it hits the breakpoint you can debug the scripts. See the below screenshot where we are finding the value of "$webapp" which webapplication value. More info: Use PowerGUI script editor for executing sharepont2010 powershell. There are two main advantages of using PowerGUI: 1. Dubugging of powershell script 2. Intellisense support So, let's start setting up PowerGUI to use with sharepoint 2010: Download and install latest version of PowerGUI. Download PowerGUI PowerPack for sharepoint. *Start PowerGUI script editor​ and go to File > Powe...