Public/Get-FoxProTableMetaData.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function Get-FoxProTableMetaData {
    <#
    .SYNOPSIS
    Displays metadata for FoxPro tables, given a location.
 
    .DESCRIPTION
    Displays metadata for FoxPro tables, given a location.
 
    .PARAMETER DataSource
    Which FoxPro location is of interest?
 
    .PARAMETER TableName
    What is the name of the table(s) of interest? Null means 'all tables'.
 
    .EXAMPLE
    $Path = 'C:\Program Files (x86)\Microsoft Visual FoxPro OLE DB Provider\Samples\Northwind'
    Get-FoxProTableMetaData -datasource $Path
    # Shows all of the tables at that location.
 
    .EXAMPLE
    $Path = 'C:\Program Files (x86)\Microsoft Visual FoxPro OLE DB Provider\Samples\Northwind'
    Get-FoxProTableMetaData -datasource $Path -TableName 'employees'
    # Shows the table named 'employees'.
 
    #>


    param (
        [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True)]
        [string] $Datasource,
        $TableName
    )

    try {
        $cn = Get-FoxProConnection -DataSource $Datasource
        Get-OleDbTableMetadata -Connection $cn -TableName $TableName |
            Select-Object TableName, Type, Description, DateCreated
    }

    finally {
        $cn.Close()
        $cn.Dispose()
    }
}