2015-06-17 182 views
0

我試圖從平面文件源連接中獲取字段列表。我嘗試了下面的PowerShell命令。從SSIS XML文件中提取信息?

[xml]$p = cat .\package.dtsx 
$p.Executable.ConnectionManager 

,並返回

 
Property             ObjectData 
--------             ---------- 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
{DelayValidation, ObjectName, DTSID, Description...}  ObjectData 
...... 

如何找到名稱的特定連接?我嘗試了以下,但它不起作用。

# Find the connection which name is "XXX" 
$p.Executable.ConnectionManager | % { $_.Property } | ? { $_.ObjectName -eq "XXX" } 

回答

0

通過玩耍,我有點想通過找到一個特定的連接。

$c = $p.Executable.ConnectionManager | ? { $_.Property[1]."#text" -eq "XXX" } 

現在需要獲取所有列。以下語句獲取xml。

$c.ObjectData.ConnectionManager.OuterXml 

但是,數據類型是整數。