SQL Server documentation using Powershell

  • Hi all

    I have been using SQL Power Doc to document my instances. https://sqlpowerdoc.codeplex.com/wikipage?title=Guide%20For%20PowerShell%20Beginners.

    I am in the process of running the conversion of the xml files to Excel.

    Is there a way to do a batch conversion of XML's? I need to be able to feed it all the XML's I've collected and then it needs to convert all of them into separate Excel documents for each server, is this possible?

    This is the code for the conversion:

    .\Convert-SqlServerInventoryClixmlToExcel.ps1 -FromPath "C:\Inventory\SQL Server Inventory.xml.gz"

  • I am on my phone client's network is down) so please bear with me.

    Perhaps something like the following will do:

    Get-Items "C:\Source Directory\*.xml" | Convert-SqlServerInventoryClixmlToExcel.ps1

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Thanks

    I tried it but it still asks for a value for the FromPath parameter

  • This might work:

    Get-Items "C:\Source Directory\*.xml" | ForEach-Object {Convert-SqlServerInventoryClixmlToExcel.ps1 -FromPath $_.FullName}

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Thanks

    It works!

    Can you give me a run-down of what is actually happening with this code?

    Thanks

  • Please forgive me going through each element as I am doing this for anyone who reads this post's thread.

    1) Return all the files and directories in the directory "C:\Source Directory\" that have an extension of "xml":

    Get-Items "C:\Source Directory\*.xml"

    2) Pipe the results from the previous operation to the next (these will be file and directory information objects in this example):

    |

    3) Perform an operation on each of the objects piped through:

    ForEach-Object {[Operation to perform]}

    4) Using $_ to refer to the current object, execute the script in the file named Convert-SqlServerInventoryClixmlToExcel.ps1 passing the value of the FullName property of the current object as the script parameter named FromPath:

    Convert-SqlServerInventoryClixmlToExcel.ps1 -FromPath $_.FullName

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Thanks

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply