Atlanta Talk

Atlanta Talk

  • Comments 7

I has a blast talking to a group of customers in Atlanta today about where PowerShell is and where it is going.  Attached is the deck I presented.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at:

Attachment: Atlanta.pptx
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
  • Jeffrey, I wish I had know you were in town!

  • Ditto, let us know the next time you drop by!

  • I'm astounded with with PS can do and at what it can't.  Maybe you can help me.  I'm looking for a way to pipe something like a WMI command to a SQL table.  With all of the things that you thought of in PS, why is it that there's ALWAYS a huge disconnect with SQL?  I find it hard to believe that I'm the only one who ever wants to put something into a DB for further processing or trending.  

    Can you comment on this for me?


    Sean McCown

  • Sean;

    Here is an example of a script that lets you work with SQL databases from PowerShell:


  • Lee,

    Thanks for responding, but I think you've misunderstood my request.  My request wasn't for reading from SQL, it's writing to SQL.

    Take the simple task of querying WMI for service info and storing that service info in SQL.  Or getting disk space usage info from Win32_volume and putting that in SQL.  The web is full of code to read from SQL, but I can't find a single example or mention of writing to a DB anywhere.

    I find it hard to believe that with all the things you guys thought of in PS, with how powerful it is, that piping things to SQL isn't one of them.

    Here's an example of what I'm talking about:

    get-WMIobject win32_volume -ComputerName MyBox | Format-Table Name, Caption, FreeSpace -AutoSize | Out-File C:\Space.txt

    this is a simple line that I would like to pipe to SQL instead of a file.  And I can't believe I'm the only one who has thought of this.

    Do you have any guidance?

    Thanks.  And I really do love the work you guys have done in PS.  I just find this to be a huge hole and I'm trying to fill it as best I can.

    Sean McCown

  • The script supports INSERT INTO as well :)

    Here's the meat of a script I use to insert into a table. The key is iterating over the object's properties using $obj.PsObject.Properties.

    $sqlStatement += "INSERT INTO [$tableName]"

    $columnDefinition = "    ( "

    $valueDefinition = "VALUES`n    ( "

    $firstItem = $true

    foreach($property in $row.PsObject.Properties)


       if($property.Value -is [DbNull]) { continue }

       if(-not $firstItem)


           $columnDefinition += ", "

           $valueDefinition += ", "


       $columnDefinition += "[$($property.Name)]"

       $propertyString = [string] $property.Value

       if($property.Value -is [DateTime])


           $propertyString = $property.Value.ToString("yyyy-MM-dd HH:mm:ss.fff")


       $escapedValue = EscapeValue($propertyString)

       $valueDefinition += "'$escapedValue'"

       $firstItem = $false


    $columnDefinition += " )"

    $valueDefinition += " )"

    $sqlStatement + "`n" + $columnDefinition + "`n" + $valueDefinition + "`n"


  • @ LEE

    Thank you for the Link from your

    blog, it's very usefull for me!


Page 1 of 1 (7 items)