0

I would like to get information like below,

SiteCollection
--- RootSite
------Site1
------------Site1.1
--------------------List1
------------Site1.2
------------Site1.3
------Site2
------Site3
------Site4

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

1

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

Official Documentation

Hope this helps!

1

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.