I'm new to Powershell and am having a problem getting a progress bar to work with a foreach-object loop (If it is even possible)
Thanks to Chris below is what I have so far, my problem here is that the progress bar gets to a point and then I get error: The 101 argument is greater than the maximum allowed range of 100:
$FolderList = Get-Content C:\Folders.txt
$i = 0
foreach( $Folder in $FolderList )
{
Write-Host $Folder
Get-ChildItem $Folder -Recurse *.pdf | foreach-object{
$fileCount = (Get-ChildItem $Folder).Count
$i += 1
Write-Progress -Activity "Counting Files" -status "Searching...." -percentComplete (($i / $fileCount)*100)
$pdf = c:\pdftk.exe $_.FullName dump_data
$NumberOfPages = [regex]::match($pdf,'NumberOfPages: (\d+)').Groups[1].Value
New-Object PSObject -Property @{
Name = $_.Name
FullName = $_.FullName
NumberOfPages = $NumberOfPages
}
}
}