SharePoint Online: How to read all the PropertyBags for a SharePoint Online Site Collection!

This time I’m sharing a new script that allows to get all PropertyBags for a Site Collection in SharePoint Online. You can download the script from the following link: How to read all property bags in a SharePoint Online Site Collection

############################################################################################################################################

#Script that gets all the property Bags 

# Required Parameters:

#  -> $sUserName: User Name to connect to the SharePoint Online Site Collection.

#  -> $sPassword: Password for the user.

#  -> $sSiteUrl: SharePoint Online Site Url

############################################################################################################################################

 

$host.Runspace.ThreadOptions = "ReuseThread"

 

#Definition of the function that allows to read property bags in SharePoint Online

function ReadSPO-PropertyBags

{

    param ($sSiteUrl,$sUserName,$sPassword)

    try

    {    

        #Adding the Client OM Assemblies        

        Add-Type -Path "E:3 Docs\10 MVP3 MVP Work\11 PS Scripts\Office 365\Microsoft.SharePoint.Client.dll"

        Add-Type -Path "E:3 Docs\10 MVP3 MVP Work\11 PS Scripts\Office 365\Microsoft.SharePoint.Client.Runtime.dll"

 

        #SPO Client Object Model Context

        $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteUrl)

        $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUserName, $sPassword)  

        $spoCtx.Credentials = $spoCredentials      

 

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        Write-Host "Reading PropertyBags values for $sSiteUrl !!" -ForegroundColor Green

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        

        $spoSiteCollection=$spoCtx.Site

        $spoCtx.Load($spoSiteCollection)

        $spoRootWeb=$spoSiteCollection.RootWeb

        $spoCtx.Load($spoRootWeb)        

        $spoAllSiteProperties=$spoRootWeb.AllProperties

        $spoCtx.Load($spoAllSiteProperties)

        $spoCtx.ExecuteQuery()                

        $spoPropertyBagKeys=$spoAllSiteProperties.FieldValues.Keys

        #$spoPropertyBagKeys

        foreach($spoPropertyBagKey in $spoPropertyBagKeys){

            Write-Host "PropertyBag Key: " $spoPropertyBagKey " - PropertyBag Value: " $spoAllSiteProperties[$spoPropertyBagKey] -ForegroundColor Green

        }        

        $spoCtx.Dispose()

    }

    catch [System.Exception]

    {

        write-host -f red $_.Exception.ToString()   

    }    

}

 

#Required Parameters

$sSiteUrl = "https://<Office365Domain>.sharepoint.com/sites/CloudShare/" 

$sUserName = "<Office365User@Office365Domain.SharePoint.com>" 

#$sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString  

$sPassword=convertto-securestring "<Office365_Password>" -asplaintext -force

 

ReadSPO-PropertyBags -sSiteUrl $sSiteUrl -sUserName $sUserName -sPassword $sPassword

 

When running the script, you should get the following output in the PowerShell ISE output:
 

image

SharePoint Online: Como leer las PropertyBags de una Colección de Sitios!

En esta ocasión os comparto un nuevo script que permite leer todas las PropertyBags de una Colección de Sitios en SharePoint Online. Podéis descargaros el script desde el siguiente enlace: How to read all property bags in a SharePoint Online Site Collection

############################################################################################################################################

#Script that gets all the property Bags 

# Required Parameters:

#  -> $sUserName: User Name to connect to the SharePoint Online Site Collection.

#  -> $sPassword: Password for the user.

#  -> $sSiteUrl: SharePoint Online Site Url

############################################################################################################################################

 

$host.Runspace.ThreadOptions = "ReuseThread"

 

#Definition of the function that allows to read property bags in SharePoint Online

function ReadSPO-PropertyBags

{

    param ($sSiteUrl,$sUserName,$sPassword)

    try

    {    

        #Adding the Client OM Assemblies        

        Add-Type -Path "E:3 Docs\10 MVP3 MVP Work\11 PS Scripts\Office 365\Microsoft.SharePoint.Client.dll"

        Add-Type -Path "E:3 Docs\10 MVP3 MVP Work\11 PS Scripts\Office 365\Microsoft.SharePoint.Client.Runtime.dll"

 

        #SPO Client Object Model Context

        $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteUrl)

        $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUserName, $sPassword)  

        $spoCtx.Credentials = $spoCredentials      

 

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        Write-Host "Reading PropertyBags values for $sSiteUrl !!" -ForegroundColor Green

        Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green

        

        $spoSiteCollection=$spoCtx.Site

        $spoCtx.Load($spoSiteCollection)

        $spoRootWeb=$spoSiteCollection.RootWeb

        $spoCtx.Load($spoRootWeb)        

        $spoAllSiteProperties=$spoRootWeb.AllProperties

        $spoCtx.Load($spoAllSiteProperties)

        $spoCtx.ExecuteQuery()                

        $spoPropertyBagKeys=$spoAllSiteProperties.FieldValues.Keys

        #$spoPropertyBagKeys

        foreach($spoPropertyBagKey in $spoPropertyBagKeys){

            Write-Host "PropertyBag Key: " $spoPropertyBagKey " - PropertyBag Value: " $spoAllSiteProperties[$spoPropertyBagKey] -ForegroundColor Green

        }        

        $spoCtx.Dispose()

    }

    catch [System.Exception]

    {

        write-host -f red $_.Exception.ToString()   

    }    

}

 

#Required Parameters

$sSiteUrl = "https://<Office365Domain>.sharepoint.com/sites/CloudShare/" 

$sUserName = "<Office365User@Office365Domain.SharePoint.com>" 

#$sPassword = Read-Host -Prompt "Enter your password: " -AsSecureString  

$sPassword=convertto-securestring "<Office365_Password>" -asplaintext -force

 

ReadSPO-PropertyBags -sSiteUrl $sSiteUrl -sUserName $sUserName -sPassword $sPassword

 

La salida por pantalla correspondiente es la siguiente:

image