3

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?

2 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.