I have a parent Directory inside which there are multiple project folders. How can I check in powershell whether a pdb exists for all the respective dlls inside all the project folders?
I tried the below but dont know how to match a pdb with the particular dll.
$source = "C:\ParentDir\*"
$Dir = get-childitem $source -recurse
$List = $Dir | where-object {$_.Name -like "*.dll"}
Any help will be greatly appreciated.
Try this:
$source = ".\Projects\"
$dlls = Get-ChildItem -Path $source -Filter *.dll -Recurse | where {!$_.PSIsContainer}
foreach ($dll in $dlls)
{
$pdb = $dll.FullName.Replace(".dll",".pdb")
if (!(Test-Path $pdb)) { Write-Output $dll }
}
It returns the fileinfo(dir) objects for every every dll that doesn't have a pdb. use fullname
property to get filepath. I provided the long answer above so to easily show how it works. To shorten it, use:
$source = ".\Projects\"
Get-ChildItem -Path $source -Filter *.dll -Recurse | where {!$_.PSIsContainer} | % { $pdb = $_.FullName.Replace(".dll",".pdb"); if (!(Test-Path $pdb)) { $_ } }