Hi @Aase Nomad ,
According to my research and testing, please get the subfolders in the list first and then get the number of items in the specified subfolder.
Please modify the code in the script , as follows:
#Get the Web
$Web = $Ctx.Web
#Get the List
$List = $web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
$Ctx.ExecuteQuery()
#sharepoint online count items in list
$subfolders=$List.RootFolder.Folders
$Ctx.Load($List.RootFolder.Folders)
$Ctx.ExecuteQuery()
foreach ($folder in $subfolders)
{
if ($folder.name -eq "<<specific folder name>>"){
return $folder.ItemCount
}
}
My test results:
items in the subfolder: Items count results:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.