Warning, /sdk/codevis/thirdparty/soci/scripts/windows/Get-ODBCList.ps1 is written in an unsupported language. File is not indexed.

0001 Function Get-ODBCList
0002 {
0003     <#
0004         .SYNOPSIS
0005             Get ODBC list.
0006 
0007         .DESCRIPTION
0008             The Get-ODBCList cmdlet to Get ODBC connectors list on specific machine.
0009                 
0010         .PARAMETER ComputerName
0011             Specifies a computer name.
0012                 
0013         .EXAMPLE
0014                 PS C:\> Get-ODBCList -ComputerName "g1","g2","g3"
0015 
0016                 ODBC                                                        ComputerName
0017                 ----                                                        ------------
0018                 SQL Server                                                  g1
0019                 Microsoft Access Driver (*.mdb, *.accdb)                    g1
0020                 Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)      g1
0021                 Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)         g1
0022                 Microsoft Access Text Driver (*.txt, *.csv)                 g1
0023                 SQL Server Native Client 10.0                               g1
0024                 SQL Native Client                                           g1
0025                 SQL Server                                                  g2
0026                 SQL Server                                                  g3
0027                 
0028         .NOTES
0029                 Author: Michal Gajda
0030                 Blog  : http://commandlinegeeks.com/
0031         #>
0032         [CmdletBinding(
0033                 SupportsShouldProcess=$True,
0034                 ConfirmImpact="Low"
0035         )]
0036         Param
0037         (
0038                 [parameter(ValueFromPipeline=$true,
0039                         ValueFromPipelineByPropertyName=$true)]         
0040                 [String[]]$ComputerName = $env:COMPUTERNAME
0041         )
0042 
0043         Begin
0044         {
0045                 $Key = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
0046                 $KeyWow64 = "SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers"
0047                 $Type = [Microsoft.Win32.RegistryHive]::LocalMachine
0048         } #End Begin
0049         
0050         Process
0051         {
0052                 Foreach($Computer in $ComputerName)
0053                 {
0054                         If(Test-Connection $Computer -Quiet)
0055                         {
0056                                 Try
0057                                 {
0058                                         $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Type, $Computer)
0059                                         $regSubKey = $regKey.OpenSubKey($Key)
0060                                         $regSubKeyWow64 = $regKey.OpenSubKey($KeyWow64)
0061                                 }
0062                                 Catch
0063                                 {
0064                                         Write-Error $_.Exception.Message -ErrorAction Stop
0065                                 }
0066                                 
0067                                 if($regSubKey -and $regSubKeyWow64)
0068                                 {
0069                                         $Bits = 64
0070                                 } #End if $regSubKey -and $regSubKeyWow64
0071                                 else
0072                                 {
0073                                         $Bits = 32
0074                                 } #End Else $regSubKey -and $regSubKeyWow64
0075                                 
0076                                 Foreach($val in $regSubKey.GetValueNames())
0077                                 {
0078                                         $log = New-Object PSObject -Property @{
0079                                                 ComputerName = $Computer
0080                                                 ODBC = $val
0081                                                 Bits = $Bits
0082                                         } #End New-Object PSObject
0083                                         
0084                                         $log
0085                                 } #End ForEach $val in $regSubKey.GetValueNames()
0086                                 
0087                                 if($Bits -eq 64)
0088                                 {
0089                                         Foreach($val in $regSubKeyWow64.GetValueNames())
0090                                         {
0091                                                 $log = New-Object PSObject -Property @{
0092                                                         ComputerName = $Computer
0093                                                         ODBC = $val     
0094                                                         Bits = 32
0095                                                 } #End New-Object PSObject
0096                                                 
0097                                                 $log
0098                                         } #End ForEach $val in $regSubKeyWow64.GetValueNames()
0099                                 } #End If $Bits -eq 64
0100                         } #End If Test-Connection $Computer -Quiet
0101                 } #End Foreach $Computer in $ComputerName
0102         } #End Process
0103         
0104         End{}
0105 } #In The End :)