Skip to content

Instantly share code, notes, and snippets.

@asadrefai
Created August 11, 2015 07:21
Show Gist options
  • Select an option

  • Save asadrefai/2f585e4b2f82c1965444 to your computer and use it in GitHub Desktop.

Select an option

Save asadrefai/2f585e4b2f82c1965444 to your computer and use it in GitHub Desktop.
Check if SharePoint Site exists using CSOM PowerShell
function CheckSiteExists()
{
param(
[Parameter(Mandatory=$true)][string]$url
)
begin{
$context = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$web = $context.Web
$context.Load($web)
try {
$context.ExecuteQuery()
return $true
}
catch {
return $false
}
}
end{
$context.Dispose()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment