I have been using PowerShell to get some site and admin details out of a SharePoint list by using Invoke-WebRequest
. In the list there are 3 person or group columns, two are for the primary and secondary admins where the last is for the sites admin group and lists its members.
The issue I'm encountering is while I can expand the primary and secondary admin fields to get there names/email addresses etc. If I use the exact same thing for the admin group it comes back with a 400 error. I suspect this is due to the admin column having its allow multiple selection ticked and so I'm not expanding it correctly.
This is the Uri that works for the 2 admin columns:
site url etc./_api/web/lists(guid''siteGUID'')/items?$select=*,Secondary_x0020_Contact/EMail,Secondary_x0020_Contact/FirstName,Secondary_x0020_Contact/LastName,Primary_x0020_Contact/EMail,Primary_x0020_Contact/FirstName,Primary_x0020_Contact/LastName&$expand=Primary_x0020_Contact,Secondary_x0020_Contact
This one returns the error when I add the 3rd person column to be expanded:
site url etc./_api/web/lists(guid''siteGUID'')/items?$select=*,Secondary_x0020_Contact/EMail,Secondary_x0020_Contact/FirstName,Secondary_x0020_Contact/LastName,Primary_x0020_Contact/EMail,Primary_x0020_Contact/FirstName,Primary_x0020_Contact/LastName,Admin_x0020_Group/EMail,Admin_x0020_Group/FirstName,Admin_x0020_Group/LastName&$expand=Primary_x0020_Contact,Secondary_x0020_Contact,Admin_x0020_Group
I have also tried to just expand the admin group with out the others with this uri but it also gave the same error:
site url etc./_api/web/lists(guid''siteGUID'')/items?$select=Admin_x0020_Group/EMail,Admin_x0020_Group/FirstName,Admin_x0020_Group/LastName&$expand=Admin_x0020_Group'
As for the header etc. I'm using the following:
$headers = @{accept = "application/json;odata=verbose"}
$response = Invoke-WebRequest -Uri $uri -Headers $headers -UseDefaultCredentials
Any advice on how to get this working would be greatly appreciated.