What PowerShell data formats are the easiest to read?

I am trying to use PowerShell with SharePoint. I would like my PowerShell scripts to load my SharePoint farm configuration from files, rather than hard-coded the configuration in the scripts or the same parameters pass each time.

This is the information I need to store.

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

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

+3
source share
2 answers

Powershell has great support for XML data, as it allows you to "dot" through the XML hierarchy. For example, suppose your data was as follows

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

You can access it like this

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

( , , ), XML, CSV ( Import -Csv Export-Csv , . SQL CE.

0

Source: https://habr.com/ru/post/1745495/


All Articles