I am a newbie with Powershell, but I need to compare two folders, to ensure that the second folder has the same sub-folders as the first folder and that both folders have the same number of files. I found this script on the web and it does part of what I wanted to do, which was list all of the sub-folders in a folder and the number of files in each folder. I have spent the better part of the day trying to figure out how to search the second folder and sub-folders, to no avail. I want to list the number of files in the second folder next to the number of files in the first folder and if the second folder does not exist, note folder does not exist.
Can someone please help?
Script: FunctionFileCount { Param ( [string]$path1 ) If (-not (Test-Path-Path$path1)){Throw"Path: $path1 not found"} $count1=0 $count1=Get-ChildItem-Path$path1| where {!$_.PSIsContainer} | Measure-Object| select-ExpandPropertycount Get-Item-Path$path1| selectPSDrive, @{N="Parent"; E={($_.PSParentPath -split"FileSystem::")[1]}}, Name, @{N="FileCount"; E={$count1}} Get-ChildItem-Path$path1| where {$_.PSIsContainer} | foreach { filecount $($_.Fullname) } } FileCount"C:\Scripts"