Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL Server documentation using Powershell Expand / Collapse
Author
Message
Posted Wednesday, March 19, 2014 3:48 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, December 18, 2014 12:03 AM
Points: 1,380, Visits: 2,708
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"
Post #1552512
Posted Wednesday, March 19, 2014 6:16 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 5:52 PM
Points: 5,831, Visits: 3,751
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!!!
Post #1552585
Posted Thursday, March 20, 2014 2:05 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, December 18, 2014 12:03 AM
Points: 1,380, Visits: 2,708
Thanks
I tried it but it still asks for a value for the FromPath parameter

Post #1552889
Posted Thursday, March 20, 2014 5:18 AM This worked for the OP Answer marked as solution


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 5:52 PM
Points: 5,831, Visits: 3,751
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!!!
Post #1552951
Posted Thursday, March 20, 2014 5:44 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, December 18, 2014 12:03 AM
Points: 1,380, Visits: 2,708
Thanks
It works!

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

Thanks
Post #1552961
Posted Thursday, March 20, 2014 6:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 5:52 PM
Points: 5,831, Visits: 3,751
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!!!
Post #1552974
Posted Thursday, March 20, 2014 6:31 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, December 18, 2014 12:03 AM
Points: 1,380, Visits: 2,708
Thanks
Post #1552980
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse