SHARE
TWEET

Powershell Microsoft OLEDB Search

a guest Jul 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .SYNOPSIS
  3.     Returns a list of all OLE DB Providers that are registered in the system
  4. .DESCRIPTION
  5.     Returns a List of all OLE DB Providers that are registered in the system
  6.  
  7.     Every element in the list has the following properties:
  8.         SOURCES_NAME
  9.         SOURCES_PARSENAME
  10.         SOURCES_DESCRIPTION
  11.         SOURCES_TYPE
  12.         SOURCES_ISPARENT
  13.         SOURCES_CLSID
  14.  
  15.     NOTE: OLE DB providers are 32-bits and 64-bits aware/specific.
  16.  
  17. .EXAMPLE
  18.     C:\PS> Get-OledbRegistered
  19.  
  20. .EXAMPLE
  21.     $list = Get-OledbRegistered
  22.     $list | ?{ $_.SOURCES_DESCRIPTION.IndexOf('SQL Server') -ge 0 }
  23.     To list all "SQL Server" providers
  24. #>
  25. function Get-OledbRegistered
  26. {
  27.     [CmdletBinding()]
  28.     [OutputType([System.Collections.Generic.List[PSObject]])]
  29.     param ()
  30.  
  31.     Process
  32.     {
  33.         $list = New-Object ([System.Collections.Generic.List[PSObject]])
  34.  
  35.         foreach ($provider in [System.Data.OleDb.OleDbEnumerator]::GetRootEnumerator())
  36.         {
  37.             $v = New-Object PSObject        
  38.             for ($i = 0; $i -lt $provider.FieldCount; $i++)
  39.             {
  40.                 Add-Member -in $v NoteProperty $provider.GetName($i) $provider.GetValue($i)
  41.             }
  42.             $list.Add($v)
  43.         }
  44.         return $list
  45.     }
  46. }
  47.  
  48. $list = Get-OledbRegistered
  49. $list | ?{ $_.SOURCES_NAME.IndexOf('Microsoft') -ge 0 }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top