I am using the PnP SharePoint powershell moudle and trying to filter a users list based on a variable.
Currently here is what I have:
$RootFolder = '/Path/To/Folder'
$folders = Get-PnPFolderItem -FolderSiteRelativeUrl $RootFolder
foreach ($folder in $folders){
$user = Get-PnPUser | Where Title -Like "*$folder.Name*"}
}
This does not return results. However, if i change | Where Title -Like "*username*"
it works fine.
The user name format is "FirstName LastName (FLastName)" and i am trying to filter based on "FLastName".
I tried single quotes and also created a variable $username = "*" +$folder.Name+ "*"
and used that variable instead but no difference.
Any thoughts would be appreciated.