Forum Discussion
If that checks SiteUrl value exists in array using PnP
As a quick clarification after having gone and fact-checked myself on what I thought I remembered about -notin (where I thought it only behaved against collections), it turns out I recalled incorrectly as it works against arrays as well. This means the suggestion I made about -notcontains likely won't make any difference.
That said, the diagnostic commands are still useful since I have no idea what the types and example data look like.
Cheers,
Lain
Hi, how would enter these type checks in the script? Can you provide please. When I run one of the provided lines, then run $listItems it just shows:
Id Title GUID
-- ----- ----
280 6185d296-1919-4179-g654-02ae6bcec4d9
281 1a4efa4f-9f82-4543-b2345-26f459ec0b45
etc....
- LainRobertsonNov 21, 2023Silver Contributor
Just the first line from your script and then the following two lines added after it:
$ListItems = Get-PnPListItem -List $List; $ListItems.FieldValuesAsText.SiteUrl.pstypenames; $ListItems.FieldValuesAsText.SiteUrl | Select-Object -First 5;Cheers,
Lain
- CardinalNightNov 21, 2023Brass ContributorI'm getting:
Id Title GUID
-- ----- ----
345 3re5761be-7187-4338-822c-c471bd7eca18
346 a6c90218-112f-41d6-8673-4787a3b5c50e
347 7f989014-499b-4f45-96ea-59ce36g25dfcf- LainRobertsonNov 21, 2023Silver Contributor
I might have to leave this for someone who uses SharePoint and the PnP module, as I can't make any sense of that output.
If the three commands from above were just being run from the command line, there should have been two sets of output:
- Output from the ".pstypenames" command; then
- Output from the ".SiteUrl | Select-Object" command.
It seems the first output is not being produced at all, which I would only expect if it were being run from within a script or function, while the second output is either not being produced, or if what you're seeing is actually it, then it is quite different to what I'd expected based on the property name (I'd expected an array or collection of strings).
That said, if the results you are seeing are actually the rows from ".SiteUrl" then that may well explain why $Site.Url is not being found in that set, though there's no point in my expanding on that.
Harm_Veenstra, is this something you're able to reproduce using the PnP module? If so, perhaps you can pick this up.
I'm getting the impression that the -notin comparison from line 16 of the original script is failing because one or both sides of the operator are complex types - which won't work. It needs to be brought back to a simple type comparison.
Cheers,
Lain