2

I want to extract list of site collection of one of the webapplication using powershell.

I found this url which does the same thing. But i want result in a text file.

http://sharepointhangout.com/powershell-how-to-extract-all-site-collections-in-webapplication/

How to get result in text file?

1

3 Answers 3

7

Just use the cmdlt Out-File.

get-spsite -limit all -WebApplication http://yourWebapplicationUrl | Out-File -FilePath "C:\Users\YourUserName\Documents\spSites.txt"
4

I have used below code to list all site collections from a Web Application into a txt file

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Get-SPWebApplication http://yourwebapp.com | Get-SPSite | Select ID, Url | Out-File -FilePath "D:\spSites.txt"
2

The above solutions are fine. But you may encounter a problem with long site names. To make sure you get long string names use:

  get-spsite -limit all -WebApplication http://yourWebapplicationUrl | Ft -autosize -wrap | Out-File -FilePath "PathToYourFile" 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.