I have written a script to get the items of a specific list leveraging the GetListItems method, but I am now being asked to join multiple lists, so I believe I must use the GetItems method. The code is essentially the same, but I am not able to get the fields back that I need. I have removed the joins and preferredfields nodes to simplify the code below. I would welcome your input:
cls #Region Configure for Remote Execution $pass = ConvertTo-SecureString "******" -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential -ArgumentList "domain\user", $pass Enter-PSSession -ComputerName SPSERVER-Authentication CredSSP -Credential:$creds Add-PSSnapin Microsoft.SharePoint.PowerShell #EndRegion $list = $web.GetList("http://webapp/site/Lists/ServerCatalog") $query = new-object Microsoft.SharePoint.SPQuery $query.query = [xml]@" <Query> <Where> <And> <And> <Neq><FieldRef Name='DeploymentStatus' /><Value Type='MultiChoice'>Build</Value></Neq> <Neq><FieldRef Name='DeploymentStatus' /><Value Type='MultiChoice'>Inactive</Value></Neq> </And> <Or> <Or> <Or> <Eq><FieldRef Name='Team' /><Value Type='Text'>AD</Value></Eq> <Eq><FieldRef Name='App_x0020_Server' /><Value Type='bit'>1</Value></Eq> </Or> <Or> <Eq><FieldRef Name='Web_x0020_Server' /><Value Type='bit'>1</Value></Eq> <Eq><FieldRef Name='SQL_x0020_DB' /><Value Type='bit'>1</Value></Eq> </Or> </Or> <Eq><FieldRef Name='Desktop' /><Value Type='bit'>1</Value></Eq> </Or> </And> </Where> </Query> "@ $query.ViewFields = [xml]@" <ViewFields> <FieldRef Name="ows_Title" /> <FieldRef Name="MgmtIP" /> <FieldRef Name="OU" /> <FieldRef Name="CNAMES" /> <FieldRef Name="Processes" /> <FieldRef Name="URLs" /> <FieldRef Name="IgnoreURLs" /> <FieldRef Name="SQL_x0020_Accounts" /> <FieldRef Name="SQLStatements" /> <FieldRef Name="App_x0020_Server" /> <FieldRef Name="SQL_x0020_DB" /> <FieldRef Name="Web_x0020_Server" /> <FieldRef Name="Desktop" /> <FieldRef Name="DeploymentStatus" /> </ViewFields> "@ $query.IncludeMandatoryColumns = $false $query.DatesInUtc = $true $items = $list.GetItems($query)