$credential = get-credential
$uri = "http://tskm/apps/systemscatalog/_vti_bin/lists.asmx?WSDL"
$listName = "Server Catalog"
# Create xml query to retrieve list.
$xmlDoc = new-object System.Xml.XmlDocument
$query = $xmlDoc.CreateElement("Query")
$viewFields = $xmlDoc.CreateElement("ViewFields")
$queryOptions = $xmlDoc.CreateElement("QueryOptions")
$query.set_InnerXml("FieldRef Name='Full Name'")
$rowLimit = "1000"
$list = $null
$service = $null
try{
$service = New-WebServiceProxy -Uri $uri -Namespace SpWs -credential $credential # -UseDefaultCredential
}
catch{
Write-Error $_ -ErrorAction:'SilentlyContinue'
}
if($service -ne $null){
try{
$list = $service.GetListItems($listName, "", $query, $viewFields, $rowLimit, $queryOptions, $null)
}
catch{
Write-Error $_ -ErrorAction:'SilentlyContinue'
}
}
$output = $list.data.row
foreach ($item in $output) {
if ($item.ows_DeploymentStatus = "Production") {
[string]$server=$item.ows_Title
[string]$status=$item.ows_DeploymentStatus
"$server - $status"
}
}
8/21/2014
Powershell: Get SharePoint List
Need to get a sharepoint list but don't have access to the server -- I just have a logon that is able to browse to the list.
In this example the list is named "Server Catalog." I retrieved the entire list and then selected entries with a specific value in a field named "DeploymentStatus"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment