Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Thursday, November 16, 2017

How to get Managed Meta Data Service Information using PowerShell in SharePoint 2013/2016


If you want to get details about the managed meta data service application, there is only onw thing which you must have.

1. Central Adin URL
2. Access to Run "Windows PowerShell ISE"

There are 3 steps.

Step 1:
$site = Get-SPSite "http://tailspin.com:21332/"
Pass Central Admin Application URL as a parameter here to get site object.

Step 2:
$taxSession = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($site, $true)
To get the taxonomy Session for the Central Admin Site. Pass on Site object here.

Step 3:
$taxSession.TermStores
This step would give you all the information about "Managed Metadata  Service" Applications which are configured on this farm as of now.



Friday, February 26, 2016

PowerShell to know the SQL Server DB Name for a site collection

SQL Server DB Name for a specific SharePoint site collection

If you are having the central admin access of SharePoint, then follow the below steps to know the Database name of a particular site collection


Follow these steps:
  1. Open Central Administration.
  2. Go to "Application Management".
  3. Click on "View all site collections".
  4. Select the site collection you need to get the database name.
  5. In the panel on the right you should see "Database Name", that's the name of the content database.


If you are not having central admin access, you can use the PowerShell to know the same.  Open SharePoint 2010 Management Shell.

PS C:\Users\<username> $url="http://<host-name>/sites/<site collection name>"
PS C:\Users\<username> $site = Get-SPSite $url
PS C:\Users\<username> $site.ContentDatabase.name
WSS_Content

So in this case "WSS_Content" is the Content Database Name which is  being used by this site collection.



Wednesday, January 27, 2016

Restore a Site Collection using PowerShell

Restoring the site collection once it gets deleted inadvertently.

You need the full URL of the site collection which you want to restore back to start. 
 
Step1 : For Example, I have a root level site collection having full URL as "http://<<host name>>:10000".
You  can execute Get-SPSite cmdlet to get the site object.
 $mysite = Get-SPSite http://<<host name>>:10000
 
Step2: You can print the GUID of that site by using "id" property of that object in last step.
PS C:\Users> $mysite.id
Guid
----
7044efc1-786f-493b-b3d5-0056add40bb9
 
Step 3: Then you can use "Get-SpDeletedSite" cmdlet with the id as a parameter to confirm the other details of that site collection such as path and deletion time.
 
PS C:\Users\> Get-SPDeletedSite $mysite.id
WebApplicationId   : 740953c9-7041-4130-994a-7d85864975d3
DatabaseId         : 78e0f455-c59d-4404-83c7-085309762fdc
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId             : 7044efc1-786f-493b-b3d5-0056add40bb9
Path               : /
DeletionTime       : 1/26/2016 9:40:22 PM
 
Step 4: Last step is to run "Restore-SPDeletedSite" cmdlet with the "-Identity" parameter. You have to pass on the same id or GUID which you got in last steps. Press 'Y' for confirmation.
 
PS C:\Users> Restore-SPDeletedSite -Identity $mysite.id
Confirm
Are you sure you want to perform this action?
Performing operation "Restore-SPDeletedSite" on Target "/".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):Y
 
After execution of step4, your site collection would get restored back.