0

For complicated certificate/remoting reasons, we cannot use the PSSnapin Microsoft.SharePoint.PowerShell. I found a tutorial using CSOM objects, see example code:

Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
$site = "https://contoso.sharepoint.com"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($site)

Is there a way to get useful farm or site information using this approach? Similar to Get-SPFarm or Get-SPSite. This is on-premises SharePoint.

1 Answer 1

0

SharePoint CSOM is client side code, it can access only site collection or below level objects. It's impossible to get farm using CSOM.

To get a site imformation using csom, below is sample code:

Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
$siteurl = "https://contoso.sharepoint.com"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($site)
$site=$context.site
$context.load($site)
$context.executequery()
write-host "URL:" $site.url  "CompatibilityLevel:"  $site.CompatibilityLevel

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.