PowerShell最容易读取的数据格式是什么?

PowerShell最容易读取的数据格式是什么?,powershell,persistence,Powershell,Persistence,我正在尝试将PowerShell与SharePoint一起使用。我希望我的PowerShell脚本从文件中加载SharePoint场配置,而不是在脚本中硬编码配置,或者每次都必须传入相同的参数 这就是我需要存储的信息 WebFrontEnds: Web1, Web2, Web3 CentralAdmin: Central1 Index: Web1 ContentWebApps: http://user1, http://user2 PowerShell是否可以轻松地从CSV、XML或其他格式加

我正在尝试将PowerShell与SharePoint一起使用。我希望我的PowerShell脚本从文件中加载SharePoint场配置,而不是在脚本中硬编码配置,或者每次都必须传入相同的参数

这就是我需要存储的信息

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

PowerShell是否可以轻松地从CSV、XML或其他格式加载此数据?

PowerShell非常支持XML数据,因为它允许您通过XML层次结构“点”数据。例如,假设您的数据为以下形式

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

您的数据似乎是关系型的(基本上是三个表,计算机、函数和映射表),因此XML和CSV(使用included和cmdlet)都可以工作,但并不完美。我建议使用SQLCE

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