0
我使用PowerShell來從MSI代碼查詢_Validation表如下...MSI SQL查詢的列標題稱爲「表」不工作
$Script:WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$Script:MSIDatabase =
$WindowsInstaller.GetType().InvokeMember("OpenDatabase",
"InvokeMethod", $null, $WindowsInstaller, @($MSIPath, 0))
$Query = "SELECT Table, Column FROM _Validation"
$Script:View = $MSIDatabase.GetType().InvokeMember("OpenView",
"InvokeMethod", $null, $MSIDatabase, ($Query))
$Script:View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View,
$null)
$Record = $View.GetType().InvokeMember("Fetch", "InvokeMethod", $null,
$View, $null)
$ValidationTable [email protected]()
While($Record -ne $null){
$Col1 = $Record.GetType().InvokeMember("StringData", "GetProperty",
$null, $Record, 1)
$Col2 = $Record.GetType().InvokeMember("StringData", "GetProperty",
$null, $Record, 2)
$ValidationTable += New-Object PsObject -Property @{Table = $Col1;
Column = $Col2}
$Record = $View.GetType().InvokeMember("Fetch", "InvokeMethod", $null,
$View, $null)
}
}
現在一切正常,除了當我使用查詢中的「表」。從研究中我瞭解到它可能是SQL中的一個轉義詞,所以我試圖將其包裹在'我已經厭倦了[我試過_Validation.Table並且沒有任何工作。 因爲我不擅長SQL,任何人都可以幫我一把嗎? 非常感謝