mozziemozz / TeamsPhoneAutomation

Automation Scripts for Microsoft Teams Phone
19 stars 6 forks source link

Benutzerinformationsliste list not found #3

Closed mdurini-swisscom closed 1 year ago

mdurini-swisscom commented 1 year ago

This command is not returning any result

$userInformationListId = (Invoke-RestMethod -Method Get -Headers $Header -Uri "https://graph.microsoft.com/v1.0/sites/$($sharePointSite.id)/lists?`$filter=displayName eq 'Benutzerinformationsliste'").value.id

as I understood, Benutzerinformationsliste is the User Information List, a hidden list containing all the users stored in a SharePoint site. Benutzerinformationsliste seems to be the German name.

mozziemozz commented 1 year ago

Yes, that's correct, sorry I forgot to mention that in the blog. The name of the list depends on the settings of your tenant.

Use this url to find out what it's called in your tenant: https://<your domain>.sharepoint.com/sites/<your site name>/_catalogs/users/simple.aspx

mdurini-swisscom commented 1 year ago

I can get the name via the url, but if i try to substitute it, I still get an empty result. If i'm running the command without the filter option in the URL, i get two lists

mozziemozz commented 1 year ago

So what is the name of the user information list in your language?

$userInformationListId = (Invoke-RestMethod -Method Get -Headers $Header -Uri "https://graph.microsoft.com/v1.0/sites/$($sharePointSite.id)/lists?`$filter=displayName eq 'Benutzerinformationsliste'").value.id

You should be able to replace Benutzerinformationsliste with the list name in your language. Keep the white spaces and the '' surrounding the name. Also keep the back tick before the `$.

This worked for me in German and English.

$userInformationListId = (Invoke-RestMethod -Method Get -Headers $Header -Uri "https://graph.microsoft.com/v1.0/sites/$($sharePointSite.id)/lists?`$filter=displayName eq 'User Information List'").value.id

mdurini-swisscom commented 1 year ago

The funny thing is that I don't get it from powershell but i can find it from the URL image

even removing the filter part from the url is not showing it

image

mozziemozz commented 1 year ago

The filter part has to be there. Otherwise it won't be found because it's hidden. If it was found without the filter, it would have made things a lot easier. I checked my tenant again yesterday. In the browser it's called User Information List but with PS I can only find it using Benutzerinformationsliste. I suggest to search what possible names in the language of your tenant are.

mdurini-swisscom commented 1 year ago

It makes sense now. you can close this issue ;) thank you

mozziemozz commented 1 year ago

I think I found a way to dynamically get the id of the user information list, regardless of the localization. https://github.com/mozziemozz/TeamsPhoneAutomation/commit/6cbb1a4b9160c0b2dcd62753868249916acbd9ab