Skip to content

Instantly share code, notes, and snippets.

@vgrem
Last active December 28, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrem/7550721 to your computer and use it in GitHub Desktop.
Save vgrem/7550721 to your computer and use it in GitHub Desktop.
Print Web Client Object properties
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.Runtime.dll'
function PrintWebProperties()
{
param(
[Parameter(Mandatory=$true)][string]$url,
[Parameter(Mandatory=$false)][System.Net.NetworkCredential]$credentials
)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$ctx.Credentials = $credentials
$web = $ctx.Web
Invoke-LoadMethod -ClientObject $web
$ctx.ExecuteQuery()
Write-Host "Web Properties:"
Write-Host "Title: $($web.Title)"
Write-Host "Url: $($web.ServerRelativeUrl)"
}
$credentials = New-Object System.Net.NetworkCredential('username', 'password','domain')
$url = 'http://contoso.intranet.com/'
PrintWebProperties $url $credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment