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.
-
1If 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.– Damjan TomicJan 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.– Boris ZinchenkoJan 30, 2018 at 10:30
1 Answer
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.
-
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