Skip to content

Instantly share code, notes, and snippets.

@alx9r
Created April 26, 2020 20:20
Show Gist options
  • Save alx9r/2b4841f8e145dfebfc6ceb0c5c5aee27 to your computer and use it in GitHub Desktop.
Save alx9r/2b4841f8e145dfebfc6ceb0c5c5aee27 to your computer and use it in GitHub Desktop.
ODBC DSN and wildcards, stackoverflow.com/questions/61398748
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