Wednesday, September 12, 2018

Fetch data from multiple lists using SPSITEDATAQUERY

I knew posting on SPSITEDATAQUERY to too old , But recently I came ac-crossed requirement to get data from multiple lists . But I am posting this to keep the query handy

SPSiteDataQuery query = new SPSiteDataQuery ();
  // Query all Web sites in this site collection.
               Query. Webs = "<Webs Scope=\"SiteCollection\">";

               //Ask for all lists created from the contacts template.
               Query. Lists = "<Lists ServerTemplate=\"105\" />";

               // Get the Title (Last Name) and First Name fields.
               query.ViewFields = "<FieldRef Name=\"Title\" />";
               query.ViewFields += "<FieldRef Name=\"FirstName\" Nullable=\"TRUE\"/>";

               DataTable results = web.GetSiteData (query); 

Manage cloud identities with Windows using PowerShell


Changing Password
Set-MsolUserPassword –UserPrincipalName siddiq.ali@mycompany.onmicrosoft.com –NewPassword Pa$$w0rd –ForceChangePassword $true


Importing bulk users in Office 365 using Powershell
$NewUsers = Import-Csv –path .\NewUsers.csv


Applying Strong Password to the users
Set-MsolUser –UserPrincipalName siddiq.ali@mycompany.onmicrosoft.com
–StrongPasswordRequired $true

Powershell to set password to get never expires
Get-MsolUser | Set-MsolUser –PasswordNeverExpires $true

Configure password expiration

Set-MsolUser –UserPrincipalName siddiqali.mohammad@mycompany.onmicrosoft.com
–PasswordNeverExpires $true

REST API to filter null values for SharePoint list items

I am working for SharePoint online and I came crossed to get sharepoint list items based on null values via OTB web-part. Using IE browser I came to knew that I finding no luck to crack it.

Solution:

1. Use @v1 parameter for your rest api
2. And append the caml query @v1using $select

http://mysharepointsite/_api/web/Lists/GetByTitle('Documents1')/GetItems(query=@v1)?@v1={"ViewXml":"<View><Query><Where><And><IsNull><FieldRef Name='Selection'/></IsNull><Eq><FieldRef Name='EmpNumber'><Value Type='Text'>51457270</Value></Eq></And></Where></Query></View>"}&$select=Title