# Invoke-WebRequest
# http://psscripts.blogspot.de/2012/09/powershell-v30-invoke-webrequest.html
# http://msdn.microsoft.com/de-de/library/jj164022.aspx
# WebClient
# http://www.information-worker.nl/2011/06/12/powershell-warmup-script/#ixzz2Qoj8h891
# Rest API Calls
# http://msdn.microsoft.com/de-de/library/fp142385.aspx
# https://sergeluca.wordpress.com/2013/01/20/sharepoint-2013-rest-odata-part-1-readingfetching-information-no-code/
# http://ericwhite.com/blog/odata-expanded/
# http://blogs.msdn.com/b/uksharepoint/archive/2013/02/22/manipulating-list-items-in-sharepoint-hosted-apps-using-the-rest-api.aspx
# Query Strings
# http://www.codetails.com/krunal-039/sharepoint-2013-and-search-with-rest-api-and-odata/20130129
Function Invoke-SharePointApiRequest {
# http://www.information-worker.nl/2011/06/12/powershell-warmup-script/#ixzz2Qoj8h891
Param(
[string] $Uri,
[string] $Method = "GET",
[Hashtable] $Headers = $null,
$Data = $null
)
$WebClient = New-Object Net.WebClient
if( $Headers -ne $null ) {
$Headers.Keys | ForEach-Object {
$WebClient.Headers.Add($_, $Headers[$_])
}
}
$WebClient.Credentials = [System.Net.CredentialCache]::DefaultCredentials
if( $Method -like "GET") {
[Xml] $WebClient.DownloadString($Uri)
} else {
[Xml] $WebClient.UploadString($Uri, $Data)
}
}
Function Get-SharePointList {
Param(
[String] $Web,
[String] $List
)
$Uri = "$Web/_api/Lists/GetByTitle('$List')"
Invoke-SharePointApiRequest -Uri $Uri -Method "Get"
}
Function Get-SharePointListItems {
Param(
[String] $Web,
[String] $List
)
$Uri = "$Web/_api/Lists/GetByTitle('$List')/Items"
$Data = Invoke-SharePointApiRequest -Uri $Uri -Method "Get"
$Data.feed.entry
}
Function Get-SharePointFormDigest {
Param(
[String] $Web
)
$ContextInfoUri = "$Web/_api/contextinfo/"
$Data = Invoke-SharePointApiRequest -Uri $ContextInfoUri -Method "POST"
$Data.GetContextWebInformation.FormDigestValue
}
Function Put-SharePointItem {
Param(
[String] $Web,
[String] $List,
[Hashtable] $Data
)
$Uri = "$Web/_api/Lists/GetByTitle('$List')/Items"
$Digest = Get-SharePointFormDigest -Web $Web
$Data["__metadata"] = @{
"type" = "SP.Data.$($List)ListItem"
}
$Headers = @{
"Content-Type" = "application/json;odata=verbose"
"X-RequestDigest" = $Digest
}
$Response = Invoke-SharePointApiRequest -Uri $Uri -Headers $Headers -Data ($Data | ConvertTo-Json) -Method "Post"
$Response.entry.content.properties
}
Use SharePoint Rest api

















