SharePoint Online: Get Site Properties using PowerShell

Requirement: Get site properties in SharePoint Online using PowerShell

SharePoint Online: PowerShell to Get Site Properties
You can get SharePoint Online site properties using SharePoint Management Shell. 
#Set Parameters
$AdminSiteURL="https://Crescent-Admin.sharepoint.com"
$SiteURL="https://Crescent.sharepoint.com/sites/marketing"

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential (Get-Credential)

#Get site properties
Get-SPOSite $SiteURL | Select *
This PowerShell gets all properties of the site
sharepoint online powershell get site properties

SharePoint Online: PowerShell to Get Web Properties
Say, you want to get last modified date of a SharePoint Online site using PowerShell, Here is the CSOM way to get site properties:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    
#Set Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"

#Get Credentials to connect
$Cred = Get-Credential

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
  
#Get the web
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.executeQuery()

#Get Properties of the Web
$SiteProperties = New-Object PSOBject
$SiteProperties | Add-Member NoteProperty Title($Web.Title)
$SiteProperties | Add-Member NoteProperty Url($Web.Url)
$SiteProperties | Add-Member NoteProperty ServerRelativeUrl($Web.ServerRelativeUrl)
$SiteProperties | Add-Member NoteProperty Description($Web.Description)
$SiteProperties | Add-Member NoteProperty Created($Web.Created)
$SiteProperties | Add-Member NoteProperty LastModified($Web.LastItemModifiedDate)
$SiteProperties | Add-Member NoteProperty AllowRSSFeeds($Web.AllowRssFeeds)
$SiteProperties | Add-Member NoteProperty CustomMasterUrl($Web.CustomMasterUrl)
$SiteProperties | Add-Member NoteProperty EnableMinimalDownload($Web.EnableMinimalDownload)
$SiteProperties | Add-Member NoteProperty ID($Web.Id)
$SiteProperties | Add-Member NoteProperty Language($Web.Language)
$SiteProperties | Add-Member NoteProperty MasterUrl($Web.MasterUrl)
$SiteProperties | Add-Member NoteProperty QuickLaunchEnabled($Web.QuickLaunchEnabled)
$SiteProperties | Add-Member NoteProperty RecycleBinEnabled($Web.RecycleBinEnabled)
$SiteProperties | Add-Member NoteProperty TreeViewEnabled($Web.TreeViewEnabled)
$SiteProperties | Add-Member NoteProperty UIVersion($Web.UIVersion)
$SiteProperties | Add-Member NoteProperty WebTemplate($Web.WebTemplate)
$SiteProperties | Add-Member NoteProperty ExcludeFromSearch($Web.NoCrawl)

$SiteProperties
SharePoint Online: Get Site Properties using PowerShell SharePoint Online: Get Site Properties using PowerShell Reviewed by Salaudeen Rajack on August 07, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.