Created
April 26, 2020 20:20
-
-
Save alx9r/2b4841f8e145dfebfc6ceb0c5c5aee27 to your computer and use it in GitHub Desktop.
ODBC DSN and wildcards, stackoverflow.com/questions/61398748
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-OdbcDriver | | |
% { | |
$id = [guid]::NewGuid().Guid.Split('-')[0] | |
$name = $_.Name | |
try { | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'Add' ` | |
-Arguments @{ | |
Name = "test_$id" | |
DsnType = 'User' | |
Platform = $_.Platform | |
DriverName = $name | |
} ` | |
-ErrorAction Stop | Out-Null | |
@{ Result = 'Success'; Name = $Name } | |
} | |
catch { | |
@{ Result = 'Failure'; Name = $Name } | |
} | |
} | | |
% {[pscustomobject]$_} | | |
Sort-Object Result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment