Try something like this instead:
Add-PSSnapin SqlServerCmdletSnapin100 -ErrorAction SilentlyContinue
Add-PSSnapin SqlServerProviderSnapin100 -ErrorAction SilentlyContinue
$searchTerm = "something"
# note the second entry is for a default instance so you would only change the word "server" and leave the "\default"
$databases = @{"server\instance"="db_name";"server\default"="db_name"}
foreach($database in $databases.Keys)
{
Set-Location ("SQLSERVER:\SQL\" + $database + "\Databases\" + $databases.Get_Item($database) + "\FileGroups")
foreach($FileGroup in Get-ChildItem){
foreach($File in $FileGroup.Files){
# in here you can build up any string you like using the logical file name and physical
# path, or whatever else, and push it into an XML file
"FileGroup=" + $FileGroup.DisplayName + ". FileName=" + $File.FileName + ". FileID=" + $File.ID
}
}
}
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato