I am trying to load the on premise SharePoint site using below PowerShell code:
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"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Publishing.dll"
$siteURL = ""
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$site = $ctx.Web
$ctx.Load($site)
$ctx.ExecuteQuery()
$pageName = "Test.aspx"
$file = $ctx.Web.GetFileByServerRelativeUrl("/SitePages/Test.aspx")
$ctx.Load($file)
$ctx.ExecuteQuery()
But I am getting this error message:
Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (500) Internal Server
Error."
At line:1 char:1
+ $ctx.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException