I would like to get information like below,

--- RootSite

I want to get this information as a JSON, I know I can get it as a csv using following PS code,

$allwebapps = Get-SPWebApplication | select url foreach ($webapp in $allwebapps) {
    Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID | Export-CSV “C:\Users\A\Desktop\Structure.csv”
-NoTypeInformation }

I am not sure if there's anything out there already or I can change this script

2 Answers 2


If you update your PowerShell version to 5, you will be able to use the standard Cmdlet ConvertTo-Json

Official Documentation

Hope this helps!


Another solution is that you get the complete site Structure using PNP Powershell and later convert this well-formed Site Template XML to JSON

Get-PnPProvisioningTemplate -Out template.pnp -Handlers Lists, SiteSecurity

You can omit the handlers if you want the default site template xml.

Read More..

Your Answer

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

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