$ErrorActionPreference = "Stop";
# Not sure if I need to load all these assemblies
Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\v4.0_15.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ManagedDTS.dll';
Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap\v4.0_15.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.DTSPipelineWrap.dll';
Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.PipelineHost\v4.0_15.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.PipelineHost.dll';
# Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap\v4.0_15.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.DTSPipelineWrap.dll';
$App = New-Object -TypeName Microsoft.SqlServer.Dts.Runtime.Application;
$PackageFullPath = 'C:\SSISPackage.dtsx'; # This is the SSIS package and has some connection managers.
$Package = $App.LoadPackage($PackageFullPath, $null, 0);
$Package.Connections # this gives an array of objects with connection managers and I would like to remove one of them.
$Package.Connections | Get-member # Object: Microsoft.SqlServer.Dts.Runtime.ConnectionManager
$App.SaveToXml($PackageFullPath, $Package, $null) # Here I would like to save the package again and when I open the solution i Visual Studio I would like it to be gone.
uj5u.com熱心網友回復:
$Package.Connections包含一個Microsoft.SqlServer.Dts.Runtime.Connections實體,它有一個.Remove()方法。
因此 - 假設您知道要洗掉的連接的索引、名稱或 ID - 請執行以下操作:
# Determine the the connection to remove, which can be specified
# as:
# "name, index, ID, or identity of the ConnectionManager object to remove."
$toRemove = 42 # sample index
$Package.Connections.Remove($toRemove)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/444145.html
標籤:电源外壳
