title: Get parent property in child select in Powershell?
body: <p>I want to include a parent level property in a child result set in Powershell and I can't figure out how to do it.  An example of what I want to do would be to include the ServerName as the first column of a pipe to get the DatabaseName and a list of Database properties of all the databases on the server similar to:</p>
  
  <pre><code>[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
  $s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "SQLSERVER"
  
  $s.Databases | select $s.Name, Name, AutoShrink, AutoClose
  </code></pre>
  
  <p>This is a simplified example of what I am trying to do, (I could easily use the Database Parent property to get the $s.Name) but I have much more complex applications where I'd like to use this similar methodology and a Parent property isn't what I am after.  Also if I could alias the $s.Name to be ServerName and the $_.Name as DatabaseName it would be the ideal output.</p>
  
  <p>EDIT:</p>
  
  <p>I have spent two days searching for how to do this online and can't find any reference.  If you happen to Google/Bing/whatever the answer, if you'd also share what you used to find it I'd be really appreciative.  I generally can find the answers to stuff, but after two days I am just throwing good time after bad.</p>