2
總的問題是:我需要從PowerShell連接到Postgres DB。 我發現,我需要先安裝ODBC驅動程序。但是,我需要將腳本重新分配給不同的機器,而且我無法在任何地方安裝ODBC。是不是有一些PowerShell ODBC模塊,我只是簡單地導入PS會話,我可以使用它來連接到數據庫?謝謝。Postgres ODBC驅動程序模塊
總的問題是:我需要從PowerShell連接到Postgres DB。 我發現,我需要先安裝ODBC驅動程序。但是,我需要將腳本重新分配給不同的機器,而且我無法在任何地方安裝ODBC。是不是有一些PowerShell ODBC模塊,我只是簡單地導入PS會話,我可以使用它來連接到數據庫?謝謝。Postgres ODBC驅動程序模塊
要回答在評論你的問題,你可以做這些事情(使用PS 3.0功能):
# List assemblies loaded
[appdomain]::currentdomain.getassemblies()
# May have to tweak 2nd argument to -like
$asm= [appdomain]::currentdomain.getassemblies() | ? name -like *npgssql*
# look at all the types in the assembly
$asm.gettypes() | out-gridview
# Pick a class that looks interesting, filter it out
$typeToExamine = $asm.gettypes() | ? name -like *whateverlooksinteresting*
$typeToExamine.getproperties()|select name
# or alternatively
$typeToExamine.getproperties()|out-gridview
# similarly with $typeToExamine.getmethods()
# Or an alternative to getMethods()/getProperties() is to create an instance
# of the type and use get-member
確實的Postgres沒有.NET連接器? – PetSerAl
@PetSerAl:是的確如此:http://www.npgsql.org/ –
我在這裏https://gist.github.com/anonymous/2e1e03c3057aa997f33b。我必須通過nuget下載Npgsql軟件包並將* .dll程序集加載到PS會話中。但是,我可以找到任何示例,下一步如何繼續。裝配中有哪些可用的方法等等。 Get-Member cmdlet在這裏沒有任何幫助:-(。任何想法的傢伙? –