#H4151.ps1
$root="."
#check if the output file exists, if so delete it
IF (Test-Path c:\temp\output.csv)
{Remove-Item c:\temp\output.csv}
# Create a file header
$output="DBProject,SQLObjects `r`n"
#get the files
$files=(dir $root -r | where {$_.extension -match "dbproj"}|Get-Item)
foreach ($file in $files)
{
#get the file naame
$ProjectName=$file.Name
$ProjectName
#get the second ItempGroup block
$fileString=Get-Content $file
$text_list=[regex]::Matches($fileString,"(.*?)") | Select-String "SuppressWarnings" | %{$_.line}
#let's add a root element to the list
$text_list=""+$text_list+""
$xd=[xml]$text_list
#get all the object Names
$xd.SelectNodes("/root/ItemGroup/Build[SuppressWarnings=4151]") | %{
$objName=($_.Include).split("\")[-1]
write-host $ProjectName,$objName;
$output=$output + $ProjectName + ","+ $objName+ "`r`n"
}
}
Out-File -filepath c:\temp\output.csv -InputObject $output -Append