Can PowerShell scripting return metadata for SQL Server to access?

dondon116
dondon116 used Ask the Experts™
on
How would you use PowerShell scripting to return general Windows Explorer metadata (Name, Size, Date Modified, Owner, etc.) from a file server for top level folders only.  And would SQL Server 2008 PowerShell integration be able to link directly to the data to query the information?  Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
PowerShell Developer
Top Expert 2010
Commented:

You can get almost everything.

This does need a note on the Size though. If you're expecting that to return for folders you must recurse through all children and sum all sizes, there isn't a persistent property we can pick on for folders.

I can't speak for SQL PowerShell Integration I'm afraid. I know you can talk to SQL using the .NET SQL Client class, but that's as near as I've got.

Chris
Get-ChildItem "WhateverTopLevelFolder"  | %{
  $Item = $_
  Get-ACL $Item.FullName | Select-Object `
    @{n='Name';e={ $Item.Name }}, `
    @{n='Size';e={ $Item.Length }}, `
    @{n='Date Modified';e={ $Item.LastWriteTime }}, `
    Owner
}

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial