views:

41

answers:

2

I'm trying to use PowerShell with SharePoint. I'd like my PowerShell scripts to load my SharePoint farm configuration from files rather than either hard coding the configuration in the scripts, or having to pass in the same parameters each time.

This the kind of information I need to store.

WebFrontEnds: Web1, Web2, Web3
CentralAdmin: Central1
Index: Web1
ContentWebApps: http://user1, http://user2

Does PowerShell easily load this data from CSV, XML, or other formats?

+3  A: 

Powershell has great support for XML data is it allows you to "dot" through an XML hierarchy. For example assume your data was in the following form

<Root>
    <WebFrontEnds>
        <Web1 />
        <Web2 />
        <Web3 />
    </WebFrontEnds>
</Root>

It could be accessed like so

C:\Users\jaredpar> $data = [xml](gc example.xml)
C:\Users\jaredpar> $data.Root.WebFrontEnds.ChildNodes | %{ $_.Name }
Web1
Web2
Web3
JaredPar
A: 

Your data appears to be relational (basically three tables, Computer, Function, and a mapping table), so both XML and CSV (using the included Import-Csv and Export-Csv cmdlets) will work but will be imperfect fits. I would suggest using SQL CE.

fatcat1111