Last active
December 28, 2015 19:29
-
-
Save vgrem/7550721 to your computer and use it in GitHub Desktop.
Print Web Client Object properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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