4

How to get SharePoint server information in CSOM function call? For instance, version of SharePoint server, to which we connected, build number, maybe other technical information. Silly enough, I cannot find relevant function or answer. Thank you.

2
  • 1
    If you don't find the csom call for this maybe you could make a simple http request to siteurl/_vti_pvt/service.cnf and parse the result? It contains the server version and encoding. Jan 30, 2018 at 10:21
  • @Damjan Tomic, Thank you for this valuable info link, on which I was not aware. I was actually looking for CSOM call because all my other calls are in CSOM. But if nobody will suggest CSOM function, I will use your suggestion. Jan 30, 2018 at 10:30

1 Answer 1

3

You can retreive that information from the Microsoft.SharePoint.Client.ClientContext class such as the following.

Basic Information

$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl);

#SharePoint Online authentication
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, (ConvertTo-SecureString $password -AsPlainText -Force));

#SharePoint On-Premise authentication
#$context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials;

$context.ExecuteQuery();

$context.ServerVersion;    
$context.ServerSchemaVersion;
$context.ServerLibraryVersion;
$context.RequestSchemaVersion;
  

Tenant Information

If you are using SharePoint Online or On-premise multi-tenancy mode (with Admin Tenant Stub installed guide here) by using the assembly Microsoft.Online.SharePoint.Client.Tenant.dll and the class Microsoft.Online.SharePoint.TenantAdministration.Tenant

$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl);

#SharePoint Online authentication
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, (ConvertTo-SecureString $password -AsPlainText -Force));

#SharePoint On-Premise authentication
#$context.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials;

$tenant = New-object Microsoft.Online.SharePoint.TenantAdministration.Tenant($context);

$context.ExecuteQuery();

$tenant.CompatibilityRange;
$tenant.DisplayStartASiteOption;
$tenant.ExternalServicesEnabled;
$tenant.NoAccessRedirectUrl;
$tenant.ResourceQuota;
$tenant.ResourceQuotaAllocated;
$tenant.RootSiteUrl;
$tenant.SharingCapability;
$tenant.StartASiteFormUrl;
$tenant.StorageQuota;
$tenant.StorageQuotaAllocated;

Hope it would help you.

1
  • thank you. It worked. It is exactly the info I was looking for. I ve marked your answer as the solution. Jan 30, 2018 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.