Reputation: 291
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.
Upvotes: 2
Views: 664
Reputation: 54891
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)) { $_ } }
Upvotes: 1
Reputation: 126792
Try this, it should output two columns, FullName, the dll path, and PDB which contains a boolean value indicating if there's a corresponding PDB file.
Get-ChildItem $source -Filter *.dll -Recurse |
Select-Object FullName,@{n='PDB';e={ Test-Path ($_.FullName -replace 'dll$','pdb') -PathType Leaf }}
Upvotes: 4