2010-05-14 20 views
3

我正在嘗試使用SharePoint的PowerShell。我希望我的PowerShell腳本從文件加載我的SharePoint場配置,而不是在腳本中對配置進行硬編碼,或者每次都必須傳入相同的參數。PowerShell最容易讀取哪些數據格式?

這是我需要存儲的信息。

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

PowerShell能否輕鬆地從CSV,XML或其他格式加載這些數據?

回答

3

Powershell對XML數據有很好的支持,它允許你通過XML層次來「點」。例如,假設你的數據在下面的表格

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

它可以像這樣

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

您的數據似乎是關係進行訪問(基本上是三個表,計算機,功能,和映射表) ,因此XML和CSV(使用包含的Import-CsvExport-Csv cmdlet)都可以工作,但不完美。我會建議使用SQL CE。