I'm trying to write a PowerShell script to count the number of pages in word documents which will end up in a database to be used as a way to assess average number of pages in documents. We have thousands of these word documents which we get from providers and my challenge is that I already have an automated solution in a system without Office apps, meaning no COM object implementation possible. I've been looking at PSWriteWord as an option but the command for getting page settings seems to only work for margin, size and orientation and does not output a page count. Does anyone have a suggestion on how to tackle this one? I'm adding the code I tried with PSWriteWord and the results in case someone sees a fluke in my method.
Import-Module PSWriteWord
$WordDocument = Get-WordDocument -FilePath 'C:\Users\user\Desktop\testdocument.docx'
Get-WordPageSettings -WordDocument $WordDocument
