Posts Tagged web site

SharePoint Online – List of Sites & Webs


Need to create a PowerShell script that iterates through all SharePoint Online site collections and webs and generate info. regarding site collection size, last time site/web update and other.


Tweaked script by Jose Quinto @

Output is two CSV files in temp folder on C drive root. One with the details and other with site collection on which account gets 401 error.

$Global:webinfo = @()

function AuthenticateUserProfile($siteUrl, $tenantAdmin, $secureAdminPassword)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($tenantAdmin, $secureAdminPassword)
$ctx.Credentials = $credentials
return $ctx

function RecursiveWebs($ctx, $web){

foreach($w in $web.Webs)

$Properties = @{
Title = $w.Title
URL = $w.Url
NoOfSubsites = $w.Webs.Count
LastUserModifiedDate = $w.LastItemUserModifiedDate
LastItemModifiedDate = $w.LastItemModifiedDate
SiteCollection = ‘No’
SiteOwner = $w.Author.Title

$Global:webinfo += New-Object psobject -Property $properties

if ($w.Webs.Count -gt 0)
RecursiveWebs $ctx $w

$username = “”
$password = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
$O365Credential = New-Object System.Management.Automation.PsCredential($username, $password)

#SharePoint Online Admin site URL
Connect-SPOService -Url -Credential $O365Credential
$sites = Get-SPOSite -Limit All -Detailed

foreach ($site in $sites)
$site.Url.Equals(“”) -or

Write-Host $site.Url
$ctx = AuthenticateUserProfile $site.Url $username $password;
$web = $ctx.Web

$Properties = @{

Title = $site.Title
URL = $site.Url
SiteSizeLimitInMB = $site.StorageQuota
SiteUsageInMB = $site.StorageUsageCurrent
NoOfSubsites = $web.Webs.Count
SiteOwner = $site.Owner
LastContentModifiedDate = $site.LastContentModifiedDate
LastUserModifiedDate = $web.LastItemUserModifiedDate
SiteCollection = ‘Yes’
LastItemModifiedDate = $web.LastItemModifiedDate

$Global:webinfo += New-Object psobject -Property $properties

if ($web.Webs.Count -gt 0)
RecursiveWebs $ctx $web
Write-Host $_ -ForegroundColor Red
$Properties1 = @{

Title = $site.Title
URL = $site.Url


$site401 += New-Object psobject -Property $properties1



$webinfo | Select-Object Title, URL, SiteSizeLimitInMB, SiteUsageInMB, LastItemModifiedDate,
LastUserModifiedDate, LastContentModifiedDate, NoOfSubsites,
SiteOwner, SiteCollection | Export-Csv -notypeinformation -Path ‘C:\temp\SPOinfo.csv’

$site401 | Select-Object Title, URL | Export-Csv -notypeinformation -Path ‘C:\temp\SPOinfo401.csv’



Comments (1)

MOSS: Microsoft Office SharePoint Designer 2007 Restore Web Sites Error (Exportsettings.xml)


error occured while importing the web http://SiteURL 

Could not find the file ‘C:\WINDOWS\TEMP\f611fafc-73d8-4b48-bc1e-f9ef6d7cb991\Exportsettings.xml’  


Microsoft Office SharePoint Designer 2007 failed to create a valid Content Migration Package (.cmp) for site having size greater than 25MB. Although, you will have a success message for backup but when you try to restore it, you will face the error of “Exportsettings.xml” file. The backup Content Migration Package (.cmp) can’t be restored. 

A typical “Exportsettings.xml” file has the following contents:  

<?xml version=”1.0″ encoding=”utf-8″ ?>

<ExportSettings xmlns:xsi=” xmlns:xsd=” SiteUrl=”http://ServerName/ FileLocation=”PathOfTheBackupFile BaseFileName=”” IncludeSecurity=”None IncludeVersions=”All ExportPublicSchema=”true ExportMethod=”ExportAll ExcludeDependencies=”true xmlns=”urn:deployment-exportsettings-schema“>


<DeploymentObject Id=”729ad10a-1ebf-48c1-bc95-ab2ffb7f5663 Type=”Web ParentId=”00000000-0000-0000-0000-000000000000 Url=”/URLOfTheSite ExcludeChildren=”false IncludeDescendants=”All” />  



The problem is that when “Microsoft Office SharePoint Designer 2007” tries to backup the site, WSS fail to create a valid Content Migration Package (.cmp). When, “Microsoft Office SharePoint Designer 2007” download first or some of the Content Migration Package (.cmp) files, other files are deleted. Thanks to the MOOS recycle bin, all the other (.cmp) files go straight to it. 


The workaround for this problem requires “Microsoft Cabinet Software Development Kit”. Download Cabsdk.exe before proceeding. 

The first step is to take the backup of the site. (For details, follow the link). We name the Content Migration Package (.cmp) as “test.cmp”.Now when your try to restore the site using Content Migration Package (.cmp) “test.cmp”, you will face the error  

“error occured while importing the web http://SiteURL

Could not find the file ‘C:\WINDOWS\TEMP\f611fafc-73d8-4b48-bc1e-f9ef6d7cb991\Exportsettings.xml’ 

To restore the site, go to the Recycle bin of the site and there you will find the files with extension “.cmp”. Example name are like “D3F44E4819C24ED6AA9F7049E04AA431.cmp”, and “D3F44E4819C24ED6AA9F7049E04AA4311.cmp”, Restore these files from recycle bin. 

Now open / refresh the site in Microsoft Office SharePoint Designer 2007 and you will see all the files at the root of the site. 

The next step is to publish these files on the local folder. Right click on the files and select “Publish Selected File..” as shown in the figure below: 


“Remote Web Site Properties” dialog box will appear, select “File System” option and “Browse” to the desired local directory as shown in the figure below:  


Click “Ok” and files will be published at the desired directory. 

Now change the extension of the files from *.cmp to *.cab and unzip to the files to a directory, say,”testdir”. (say path C:\testdir) 

Run Console and move to the bin directory of the “Microsoft Cabinet Software Development Kit”. Run the command  cabarc n C:\testdir\*.* A cab file with the name will be created in the bin directory of “Microsoft Cabinet Software Development Kit”. Change the extension of the file from and “*.cab” to “.cmp” and use this file to restore the site. 

In case you may encounter an error, try adding the original back up file “test.cmp” into the “testdir” directory or adding all the files from the site recycle bin into the “testdir” directory.

Comments (64)

MOSS: Back up and Restore Web Sites Using Microsoft Office SharePoint Designer 2007

Microsoft Office SharePoint Designer 2007 is a good resource for backup and restore. It creates a content migration package (.cmp) for the web site.

The content migration package contains library content, list content, navigation, user information, security settings, personalize settings like views and content types and customization but content migration package does not contain alerts, workflows and properties.  


The first step is open the site in Microsoft Office SharePoint Designer 2007 and move from Site menu to Administration and click on Back Web Site.  

Backup Web Site dialog box will appear which will ask to include all the sub sites in the backup, do as appropriate and click OK.  

File Save dialog box will appear, guide it to the desired location after entering the name of the .cmp file and hit OK.  

Microsoft Office SharePoint Designer 2007 will take time to crate content migration package depending upon the size of the web site.  


First we will create an empty web site for restoring. For this, open Microsoft Office SharePoint Designer 2007 and move from File menu to New and click on Web Site. 

In the New Dialog box, select Web Site tab, then select General and then Empty Web Site. Give the desired URL  in the text box at the bottom of the dialog box and click OK. Microsoft Office SharePoint Designer 2007 will create a new empty web site.  

Now, move from Site menu to Administration and click on Restore Web Site. Browse to the desired  content migration package (.cmp file) and click OK.

This will start restoring the site and success message  will appear at the end of the process.  


Error occurred while exporting the web http://site URL.

Access is denied.(Eception from HRESULT:0x8007005(E_ACCESSDENIED)) 


You are not the administrator of the site collection. 


Add yourself as site administrator. For this, open SharePoint Central Administration. Move from “Application Management” to “Site collection administrators” under  “SharePoint Site Management”. Add yourself as administrator in the appropriate site collection.

Comments (9)