Eulanda / EulandaConnect

A PowerShell library that provides functionality for integrating and connecting with Eulanda, both within and outside of ERP contexts.
https://www.eulanda.eu
MIT License
1 stars 0 forks source link

Add function New-UdlFromConn #21

Open cnEUL opened 1 year ago

cnEUL commented 1 year ago

Add a function that creates a connItems from an ADO connection and creates a UDL file from it.

$connItems = @{}
        $filteredContent -split ';' | ForEach-Object {
            $keyValue = $_ -split '='
            if ($keyValue.Count -eq 2) {
                $key = $keyValue[0].Trim()
                $value = $keyValue[1].Trim()
                if ($key -ne '') {
                    $connItems [$key] = $value
                }
            }
        }

        $connStr = ($masterConnItems.GetEnumerator() | ForEach-Object {
            "$($_.Key)=$($_.Value)"
        }) -join ';'

        $udlContent = @"
        [oledb]
        ; Everything after this line is an OLE DB initstring
        $connStr
        "@

        $udlContent | Out-File -FilePath $udlFilePath -Encoding Unicode